AI开发平台MODELARTS-模型配置文件编写说明:图像分类模型配置文件示例

时间:2024-08-16 20:39:15

图像分类模型配置文件示例

如下代码以TensorFlow引擎为例,您可以根据实际使用的引擎类型修改model_type参数后使用。

  • 模型输入

    key:images

    value:图片文件

  • 模型输出
    1
    2
    3
    4
    5
    6
    7
    {
        "predicted_label": "flower",
        "scores": [
           ["rose", 0.99],
           ["begonia", 0.01]
        ]
    }
    
  • 配置文件
     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
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    {
        "model_type": "TensorFlow",
        "model_algorithm": "image_classification",
        "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",
                    "properties": {
                        "predicted_label": {
                            "type": "string"
                        },
                        "scores": {
                            "type": "array",
                            "items": [{
                                "type": "array",
                                "minItems": 2,
                                "maxItems": 2,
                                "items": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "number"
                                    }
                                ]
                            }]
                        }
                    }
                }
            }
        }],
        "dependencies": [{
            "installer": "pip",
            "packages": [{
                    "restraint": "ATLEAST",
                    "package_version": "1.15.0",
                    "package_name": "numpy"
                },
                {
                    "restraint": "",
                    "package_version": "",
                    "package_name": "Pillow"
                }
            ]
        }]
    }
    

如下代码以MindSpore引擎为例,您可以根据实际使用的引擎类型修改model_type参数后使用。

  • 模型输入

    key:images

    value:图片文件

  • 模型输出
    1
    "[[-2.404526   -3.0476532  -1.9888215   0.45013925 -1.7018927   0.40332815\n  -7.1861157  11.290332   -1.5861531   5.7887416 ]]"
    
  • 配置文件
    {
         "model_algorithm": "image_classification",
         "model_type": "MindSpore",
         "metrics": {
             "f1": 0.124555,
             "recall": 0.171875,
             "precision": 0.0023493892851938493,
             "accuracy": 0.00746268656716417
         },
         "apis": [{
                 "url": "/",
                 "method": "post",
                 "request": {
                     "Content-type": "multipart/form-data",
                     "data": {
                         "type": "object",
                         "properties": {
                             "images": {
                                 "type": "file"
                             }
                         }
                     }
                 },
                 "response": {
                     "Content-type": "applicaton/json",
                     "data": {
                         "type": "object",
                         "properties": {
                             "mnist_result": {
                                 "type": "array",
                                 "item": [{
                                     "type": "string"
                                 }]
                             }
                         }
                     }
                 }
             }
         ],
        "dependencies": []
     }
support.huaweicloud.com/usermanual-standard-modelarts/inference-modelarts-0056.html