AI开发平台MODELARTS-模型配置文件编写说明:自定义镜像类型的模型配置文件示例

时间:2023-11-21 09:08:24

自定义镜像类型的模型配置文件示例

模型输入和输出与目标检测模型配置文件示例类似。

  • 模型预测输入为图片类型时,request请求示例如下:

    该实例表示模型预测接收一个参数名为images、参数类型为file的预测请求,在推理界面会显示文件上传按钮,以文件形式进行预测。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    {
        "Content-type": "multipart/form-data",
        "data": {
            "type": "object",
            "properties": {
                "images": {
                    "type": "file"
                }
            }
        }
    }
    
  • 模型预测输入为json数据类型时,request请求示例如下:

    该实例表示模型预测接收json请求体,只有一个参数名为input、参数类型为string的预测请求,在推理界面会显示文本输入框,用于填写预测请求。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    {
        "Content-type": "application/json",
        "data": {
            "type": "object",
            "properties": {
                "input": {
                    "type": "string"
                }
            }
        }
    }
    

完整请求示例如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
    "model_algorithm": "image_classification",
    "model_type": "Image",
    "metrics": {
        "f1": 0.345294,
        "accuracy": 0.462963,
        "precision": 0.338977,
        "recall": 0.351852
    },
    "apis": [{
        "url": "/",
        "method": "post",
        "request": {
            "Content-type": "multipart/form-data",
            "data": {
                "type": "object",
                "properties": {
                    "images": {
                        "type": "file"
                    }
                }
            }
        },
        "response": {
            "Content-type": "application/json",
            "data": {
                "type": "object",
                "required": [
                    "predicted_label",
                    "scores"
                ],
                "properties": {
                    "predicted_label": {
                        "type": "string"
                    },
                    "scores": {
                        "type": "array",
                        "items": [{
                            "type": "array",
                            "minItems": 2,
                            "maxItems": 2,
                            "items": [{
                                    "type": "string"
                                },
                                {
                                    "type": "number"
                                }
                            ]
                        }]
                    }
                }
            }
        }
    }]
}
support.huaweicloud.com/inference-modelarts/inference-modelarts-0056.html