虚拟试穿生成任务提交API调用说明

虚拟试穿生成任务提交

GET/POST /ai/virtual/model/generation/batch

虚拟试衣产品能够根据服饰平铺图,取代真人模特拍摄,快速生成模特上身图片。该产品能大幅降低模特图片拍摄成本,有效提升服饰类商品图片展现效果。

注:该接口是异步接口,您需要先提交任务,获取任务id后,调用结果查询接口获取生成结果。当前API为第一步任务提交API。

请求参数

参数参数类型必填描述

requestParams

Object[]

请求参数

clothesList

List<Object>

需要上身的服饰图片列表,目前仅支持单件服饰试穿

imageUrl

String

模特图片URL。

imageBase64不能同时为空。如果同时存在imageUrlimageBase64,优先取 Base64。

图片尺寸应该大于512*512像素,小于3000*3000像素。

type

String

modelImage

List<String>

用户自行上传的模特图URL列表,将优先使用该入参模特图进行生成,生成图片取决于上传的模特图数量。若无自己模特图可填入下面model参数使用模特库内模特,单次最多支持8张模特图生成

示例值:[“URL1", "URL2"]

默认为空

model

Object

用户选定用作虚拟试衣的模特类型或某位模特

base

String

需要调用的模特库,如业务已定制模特库,则通过填写业务专属场景码调用定制化模特库

通用模特库:“General”

默认为"General"

name

String

模特的姓名,可指定对应模特库内某位模特,模特姓名参照表请参考模特库文档,指定模特姓名后,剩余模特参数将无效

示例:"Ariel"

默认为空

gender

String

需要上身的模特性别

"male":男模 "female":女模

默认为"female"

style

String

需要上身的模特风格;如为 业务定制化模特,具体风格标签请参照模特库文档;

默认为"universal_1"

"universal_1":示例1,示例2

"universal_2":示例3,示例4

body

String

需要上身的模特身材类型

"slim":标准模特

"curvy":大码模特

默认为"slim"

viewType

String

生成效果图的视角

"fullbody":全身图

"halfbody":半身图

“mixed:全身图&半身图混合

默认为"fullbody"

imageNum

Number

生成图片数量,支持1-8输入

默认为4

inputQualityDetect

Number

是否需要自动过滤低质量,非完整平铺的输入服饰图片 "1":需要

"0": 不需要

默认为0,建议批量场景,图片质量不稳定时启用

请求示例

输入限制:

  • 图像格式:JPEG、JPG、PNG、BMP、WEBP。

  • 图像大小:不超过 4 MB。

  • 图像分辨率:输入图片尺寸大于 512×512 像素,小于 3000×3000 像素。

  • 品类范围:目前模特换肤API仅支持“服装”品类的自动分割和保留,暂不支持其他指定品类商品。

IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/virtual/tryon");
request.addApiParameter("requestParams", "[{\"clothesList\":[{\"imageUrl\":\"https://ae-pic-a1.aliexpress-media.com/kf/H7588ee37b7674fea814b55f2f516fda1z.jpg\",\"type\":\"tops\"}],\"model\":{\"base\":\"General\",\"gender\":\"female\",\"style\":\"universal_1\",\"body\":\"slim\"},\"viewType\":\"mixed\",\"inputQualityDetect\":0,\"imageNum\":4}]");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);
IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/virtual/tryon");
String newRequestParams = "[{\"requestParams\":{\"clothesList\":[{\"imageUrl\":\"https://ae-pic-a1.aliexpress-media.com/kf/H7588ee37b7674fea814b55f2f516fda1z.jpg\",\"type\":\"tops\"}],\"model\":{\"base\":\"General\",\"name\":\"James\"},\"viewType\":\"mixed\",\"inputQualityDetect\":0,\"imageNum\":4}}]";
request.addApiParameter("requestParams", newRequestParams);
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);
IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/virtual/tryon");
String newRequestParams = "[{\"requestParams\":{\"clothesList\":[{\"imageUrl\":\"https://ae-pic-a1.aliexpress-media.com/kf/H7588ee37b7674fea814b55f2f516fda1z.jpg\",\"type\":\"tops\"}],\"modelImage\":[\"http://ai-business-algo-pai.oss-ap-southeast-1.aliyuncs.com/pengxin.zpx%2Fdatasets%2Ftest_images%2F365b8862-71cb-11ef-a6f9-964d09221cfd.png?OSSAccessKeyId=LTAI5tAGoBnm5eYsnZ5E1zMr&Expires=1883910332&Signature=ebJZT4eoEN3kpsSiSpK4minOdRM%3D\"]}}]";
request.addApiParameter("requestParams", newRequestParams);
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);

响应参数

参数参数参数类型Description

requestId

String

唯一的请求ID。用于排查问题。

success

Boolean

返回的请求状态,代表请求是否成功。

resCode

Number

返回的结果码,其中200代表成功,详细错误码请参考错误码列表。

resMessage

String

返回的请求信息。

data

Object

返回的json结果数据。

result

Object

返回的结果数据。

taskId

String

唯一的任务ID。用于后续的请求结果查询。

返回示例

{
  "code": "0",
  "data": {
    "result": "{\"taskId\":\"1ce4fd33-b9d5-4e21-a24c-0c4027d2b105\"}"
  },
  "requestId": "212cd83017085872506144758e3fca",
  "success": "true",
  "resCode": "200",
  "resMessage": "success",
  "request_id": "0ba2887315178178017221014"
}

错误码

错误码错误信息描述

500

system error

System error.服务器内部错误

501

rate limit exceed

当前接口已达到限流上限,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们增加当前限制值。

700

invalid input

输入参数的格式不符合要求,resMessage 将返回详细的不符合要求的字段。

701

Clothing image dowloading failed, please try another input

服饰图下载失败,请尝试其他输入。

703

Input clothes image resoulution low, please try other image

服饰图分辨率不符合要求,请尝试其他图片。

707

Input clothing image is not a complete flat lay. Please try another image.

服饰图片非完整平铺图,质量不符合虚拟试衣要求,请尝试其他图片。

801

model failed

内部调用异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们进行故障排除。

1000

content has sensitive data, please try other input

内容包含敏感数据,无法处理,请尝试其他输入。

1001

content control failed, please retry

风控服务运行异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们。

1002

content risk filter failed, please contact us

风控服务运行异常,请搜索Aidge产品咨询&服务群钉钉群号:105455001046,入群联系我们。

Last updated