AI试衣图片精修API详情

模型概览

模型名

模型简介

aitryon-refiner

aitryon-refiner是一款图像优化模型,它作为aitryon模型的辅助,可基于aitryon生成的试衣效果图和原始输入图,生成还原度更高、更加逼真的试衣效果图,使图片中的细节更加精确、色彩更加饱满。

模型效果与输入要求

模型效果示例

AI试衣生成效果

图片精修生成效果

test_client_tryon

result_refiner

输入限制

  • 传入的服饰图与模特图应与调用AI试衣API时输入的素材保持一致

  • 图片格式:支持jpg、jpeg、png、bmp、heic

  • 文件大小:5KB~5MB之间

  • 分辨率:大于150*150 px,最大边长小于4096 px,最小边长大于150 px

  • 上传图片仅支持HTTP链接,不支持本地路径

HTTP调用接口

功能描述

用于生成人物试衣精修图片。

前提条件

作业提交接口

POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis/
说明
  • 因该算法调用耗时较长,故采用异步调用的方式提交任务。

  • 任务提交之后,系统会返回对应的作业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,应与输入AI试衣API的入参top_garment_url相同。

  • 5KB≤图像文件≤5M

  • 150≤图像边长≤4096

  • 格式支持:jpg、png、jpeg、bmp、heic

  • 需上传服饰平拍图,保持服饰是单一主体且完整,背景干净,四周不宜留白过多

  • 上传图片仅支持HTTP链接,不支持本地路径

http://aaa/bbb.jpg

input.bottom_garment_url

String

Body

用户上传的下半身服饰图片的原图 URL,应与输入AI试衣API的入参bottom_garment_url相同。

  • 5KB≤图像文件≤5M

  • 150≤图像边长≤4096

  • 格式支持:jpg、png、jpeg、bmp、heic

  • 需上传服饰平拍图,保持服饰是单一主体且完整,背景干净,四周不宜留白过多

  • 上传图片仅支持HTTP链接,不支持本地路径

http://aaa/bbb.jpg

input.person_image_url

String

Body

用户上传的模特人物图片的原图 URL, 应与输入AI试衣API的入参person_image_ur相同。

  • 5KB≤图像文件≤5M

  • 150≤图像边长≤4096

  • 格式支持:jpg、png、jpeg、bmp、heic

  • 需保持图片中有且仅有一个完整的人

  • 上传图片仅支持HTTP链接,不支持本地路径

http://aaa/bbb.jpg

input.coarse_image_url

String

Body

调用AI试衣API生成的试衣结果图的 URL。

  • 5KB≤图像文件≤5M

  • 150≤图像边长≤4096

  • 格式支持:jpg、png、jpeg、bmp、heic

说明

使用试衣精修功能,需在调用AI试衣API时,设参数resolution为-1,restore_facetrue。

http://aaa/bbb.jpg

parameters.gender

String

Body

用户上传person_image中人物的性别,辅助提升refiner效果。可选值为womanman。

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"
}

作业任务状态查询和结果获取接口

GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}

入参描述

字段

类型

传参方式

必选

描述

示例值

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 排队中

  • PRE-PROCESSING 前置处理中

  • RUNNING 处理中

  • POST-PROCESSING 后置处理中

  • SUCCEEDED 成功

  • FAILED 失败

  • UNKNOWN 作业不存在或状态未知

output.image_url

Array

生成的结果物地址,

image_url有效期为作业完成后24小时

{"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",
	"submit_time": "2024-xx-xx xx:xx:xx.xxx", 
	"scheduled_time": "2024-xx-xx xx:xx:xx.xxx", 
	"end_time": "2024-xx-xx xx:xx:xx.xxx",
        "image_url":"YOUR_IMAGE_URL",
    },
    "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": "xxx",
        "message": "xxxxxx"
  }
}

状态码说明

大模型服务通用状态码请查阅:错误码

同时本模型还有如下特定错误码:

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.

图片URL访问失败,请检查URL或文件格式

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.

上传图片大小不符合要求

400

InvalidParameter

The size of person image and coarse_image are not the same.

coarse_image分辨率和person_image不一致,应保持一致