文档

快速开始

更新时间:

前提条件

AI试衣

AI试衣(OutfitAnyone)是通义实验室自主研发的虚拟试衣模型服务产品。用户无需亲临实体店或经历繁琐的试穿过程,仅需上传服装平铺图以及正面全身人像照,便能生成高质量试衣效果,精准展现衣物穿着后的实际观感。

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

功能描述:

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

请求示例:

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",
    "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"
    },
    "parameters": {
        "resolution": -1,
        "restore_face": true
    }
  }'

响应示例:

{
    "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 的形式返回给客户供客户下载。

请求示例:

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

AI试衣 - 图片精修

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

功能描述:

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

请求示例:

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 的形式返回给客户供客户下载。

请求示例:

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