文档

AI试衣图片精修API详情

更新时间:
一键部署

图片精修生成效果

基于AI试衣服务生成初步试衣效果图后,我们利用OutfitAnyone的图像处理技术对其进行精修处理,输出还原度更高、更加逼真的试衣效果图,确保细节更加精确、色彩更加饱满,为用户带来身临其境的试衣体验。

生成效果示意:

AI试衣生成效果

图片精修生成效果

test_client_tryon

result_refiner

API 接口

1. 试衣Refiner的pipeline提交任务接口调用(POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/)

功能描述:

因为算法属于时间相对较长的算法调用,通常情况下,1张图片大概需要 45 秒左右的生成时间,所以需要采用异步调用的方式提交任务,任务提交之后,系统会返回对应的作业 ID,随后客户通过对应的异步作业查询接口获取任务状态以及在作业结束后取回对应结果。

入参描述:

字段

类型

传参方式

必选

描述

示例值

Content-Type

String

Header

请求类型:application/json

application/json

Authorization

String

Header

API-Key,例如:Bearer d1**2a

Bearer d1**2a

X-DashScope-Async

String

Header

使用 enable,表明使用异步方式提交作业。

enable

model

String

Body

指明需要调用的文生图模型。

aitryon-refiner

input.top_garment_url

String

Body

用户上传的上半身服饰图片的原图 URL,应与用户上传的第一阶段试衣输入top_garment_url相同, 图片大小应在5KB~5MB,图像格式限于jpg/png/jpeg/bmp,最大边长小于等4096,最小边大于150.

尽量保持服饰是单一主体且完整,背景干净,四周不宜留白过多。

http://aaa/bbb.jpg

input.bottom_garment_url

String

Body

用户上传的下半身服饰的原图 URL, 应与用户上传的第一阶段试衣输入bottom_garment_url相同, 图片大小应在5KB~5MB,图像格式限于jpg/png/jpeg/bmp,最大边长小于等4096, 最小边大于150. 当不需要下装时(比如上装是连衣裙),该值置为空。

尽量保持服饰是单一主体且完整,背景干净,四周不宜留白过多。

http://aaa/bbb.jpg

input.person_image_url

String

Body

用户上传的模特人物图片的原图 URL, 应与用户上传的第一阶段试衣输入person_image_ur相同,图片大小应在5KB~5MB,图像格式限于jpg/png/jpeg/bmp,最大边长小于等4096,最小边大于150.

http://aaa/bbb.jpg

input.coarse_image_url

String

Body

用户上传的第一阶段试衣结果图的 URL, 图片大小应在5KB~5MB,图像格式限于jpg/png/jpeg/bmp,最大边长小于等4096,最小边大于150.

http://aaa/bbb.jpg

parameters.gender

String

Body

用户上传person_image中人物的性别,内容是woman或man,辅助提升refiner效果。

man

出参描述:

字段

类型

描述

示例值

output.task_id

String

提交异步任务的作业 id,实际作业结果需要通过异步任务查询接口获取。

a8532587-fa8c-4ef8-82be-0c46b17950d1

output.task_status

String

提交异步任务后的 作业状态。

“PENDING”

request_id

String

本次请求的系统唯一码

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例:
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/' \
--header 'X-DashScope-Async: enable' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "aitryon-refiner",
    "input": {
        "top_garment_url": "https://dashscope-swap.oss-cn-beijing.aliyuncs.com/aa-test/sample-top.jpg",
        "bottom_garment_url": "https://dashscope-swap.oss-cn-beijing.aliyuncs.com/aa-test/sample-bottom.jpg",
        "person_image_url": "https://dashscope-swap.oss-cn-beijing.aliyuncs.com/aa-test/sample-person.png",
        "coarse_image_url": "https://dashscope-swap.oss-cn-beijing.aliyuncs.com/aa-test/result.png"
    },
    "parameters": {
        "gender": "woman"
    }
 }'
响应示例
{
    "output": {
	"task_id": "a8532587-fa8c-4ef8-82be-0c46b17950d1", 
    	"task_status": "PENDING"
    }
    "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51"
}

2. 异步任务查询接口(GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}

功能描述:

异步任务接口在任务提交之后就可以获取到对应的 task_id,随后客户可以通过标准的任务查询接口查询作业的状态以及获取到最终任务的生成结果;其中生成的视频将会存储在 OSS 中以 URL 的形式返回给客户供客户下载。

入参描述:

字段

类型

传参方式

必选

描述

示例值

Authorization

String

Header

API-Key,例如:Bearer d1**2a

Bearer d1**2a

task_id

String

Url Path

需要查询作业的 task_id

a8532587-fa8c-4ef8-82be-0c46b17950d1

出参描述:

字段

类型

描述

示例值

output.task_id

String

查询作业的 task_id

a8532587-fa8c-4ef8-82be-0c46b17950d1

output.task_status

String

被查询作业的作业状态

任务状态:

PENDING 排队中

RUNNING 处理中

SUCCEEDED 成功

FAILED 失败

UNKNOWN 作业不存在或状态未知

output.results.image_url

Array

如果作业成功,包含模型生成的结果 object,然后每个 object 中包含按照要求生成的结果地址

{"image_url":"https://xxx/1.jpg"}

usage.image_count

Int

本次请求生成图片张数

"image_count": 1

request_id

String

本次请求的系统唯一码

7574ee8f-38a3-4b1e-9280-11c33ab46e51

请求示例:
curl -X GET \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
https://dashscope.aliyuncs.com/api/v1/tasks/<your_task_id>
响应示例
{
    "output":{
        "task_id":"a8532587-fa8c-4ef8-82be-0c46b17950d1",
	"task_status":"SUCCEEDED",
        "results":
            {
        "image_url":"<YOUR_RESULT>"
            }
    },
    "usage":{
        "image_count": 1
    },
    "request_id":"7574ee8f-38a3-4b1e-9280-11c33ab46e51"
}
异常响应示例
{
    "request_id": "6bf4693b-c6d0-933a-b7b7-f625d098d742",
    "output": {
        "task_id": "e32bd911-5a3d-4687-bf53-9aaef32213e9",
        "task_status": "FAILED",
        "code": "InvalidInputLength",
        "message": "The image resolution is invalid,  please make sure that the largest length of image is smaller than 4096, and the smallest length of image is larger than 150. and the size of image ranges from 5kb to 5mb"
  }
}

非标准错误码

HTTP 返回码

错误码(code)

错误信息(message)

含义说明

400

InvalidParameter

The request is missing required parameters or in a wrong format, please check the parameters that you send.

入参格式不对

400

InvalidURL

The request URL is invalid, please check the request URL is available and the request image format is one of the following types: JPEG, JPG, PNG, BMP, and WEBP.

输入图片下载失败,请检查网络或者输入格式

400

InvalidPerson

The input image has no human body or multi human bodies. Please upload other image with single person.

输入图片中没有人或多人主体

400

InvalidInputLength

The image resolution is invalid, please make sure that the largest length of image is smaller than 4096, and the smallest length of image is larger than 150. and the size of image ranges from 5KB to 5MB

上传图片大小不符合要求

  • 本页导读 (1)