AI开发平台MODELARTS-创建AI应用:请求示例

时间:2024-11-22 17:40:55

请求示例

创建AI应用。设置AI应用名称为“mnist”,版本为“1.0.0”,类型为“TensorFlow”,模型文件来源于OBS桶。

POST https://{endpoint}/v1/{project_id}/models

{
  "model_name" : "mnist",
  "model_version" : "1.0.0",
  "source_location" : "https://models.obs.xxxxx.com/mnist",
  "source_job_id" : "55",
  "source_job_version" : "V100",
  "model_type" : "TensorFlow",
  "runtime" : "python2.7",
  "description" : "mnist model",
  "execution_code" : "https://testmodel.obs.xxxxx.com/customize_service.py",
  "input_params" : [ {
    "url" : "/v1/xxx/image",
    "protocol" : "http",
    "method" : "post",
    "param_name" : "image_url",
    "param_type" : "string",
    "min" : 0,
    "max" : 9,
    "param_desc" : "http://test/test.jpeg"
  } ],
  "output_params" : [ {
    "url" : "/v1/xxx/image",
    "protocol" : "http",
    "method" : "post",
    "param_name" : "face_location",
    "param_type" : "box",
    "param_desc" : "face_location param value description"
  } ],
  "dependencies" : [ {
    "installer" : "pip",
    "packages" : [ {
      "package_name" : "numpy",
      "package_version" : "1.5.0",
      "restraint" : "ATLEAST"
    } ]
  } ],
  "model_algorithm" : "object_detection",
  "model_metrics" : "{\"f1\":0.52381,\"recall\":0.666667,\"precision\":0.466667,\"accuracy\":0.625}",
  "apis" : [ {
    "url" : "/v1/xxx/image",
    "protocol" : "http",
    "method" : "post",
    "input_params" : {
      "type" : "object",
      "properties" : {
        "image_url" : {
          "type" : "string"
        }
      }
    },
    "output_params" : {
      "type" : "object",
      "properties" : {
        "face_location" : {
          "type" : "box"
        }
      }
    }
  } ],
  "initial_config" : "{\"protocol\":\"http\",\"port\":\"8080\",\"health\":{\"check_method\":\"HTTP\",\"protocol\":\"http\",\"url\":\"/health\",\"period_seconds\":\"5\",\"failure_threshold\":\"10\",\"initial_delay_seconds\":\"12\"},\"readiness_health\":{\"check_method\":\"HTTP\",\"protocol\":\"http\",\"url\":\"/readiness_health\",\"period_seconds\":\"5\",\"failure_threshold\":\"20\",\"initial_delay_seconds\":\"12\"},\"startup_health\":{\"check_method\":\"HTTP\",\"protocol\":\"http\",\"url\":\"/startup_health\",\"period_seconds\":\"5\",\"failure_threshold\":\"10\",\"initial_delay_seconds\":\"12\"}}"
}
support.huaweicloud.com/api-modelarts/CreateModel.html