Virtual Model Alternation Submit API Reference

Virtual Model Alternation Submit

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

The Virtual Model Alternation can automatically retain the clothing area in the model image and intelligently match the model type to generate diverse models from different countries, showcasing the best wear effect of the product. This allows for localized content targeting for cross-border markets, accurately capturing user preferences and reducing photograph costs.

This is an asynchronous interface that you need to submit the task first, then obtain the task ID and call the result query interface to get the generated result. The current API is the first step, which is the task submission API.

Request Parameters

Parameter
Type
Required
Description

requestParams

Object[]

Yes

imageUrl

String

No

The model image URL.

Both imageUrl and imageBase64 cannot be empty at the same time. If both imageUrl and imageBase64 are present, Base64 is preferred.

Input image size larger than 512×512 pixels, but smaller than 3000×3000 pixels.

imageBase64

String

No

The Base64 encoding of the model image.

Both imageUrl and imageBase64 cannot be empty at the same time. If both imageUrl and imageBase64 are present, Base64 is preferred.

Input image size larger than 512×512 pixels, but smaller than 3000×3000 pixels.

imageStyle

String

Yes

Specifies the content type of the model in the submitted image, such as real person model, complete mannequin, incomplete mannequin, etc. Currently, only real person model images are supported. Range of values:

realPhoto:Submit a real person model phoyo

Sample: realPhoto

model

String

Yes

Specifies the model that needs to be generated. Currently, four different models are supported. Range of values:

universal_model_1:

universal_model_2:

universal_model_3:

universal_model_4:

Sample: universal_model_1

gender

String

No

Specifies the gender of the model to be generated. If not set, the algorithm's automatic recognition result is used by default. Range of values:

MALE: male

FEMALE: female

Sample: MALE

age

String

No

Specifies the age group of the model to be generated. If not set, the algorithm's automatic recognition result is used by default. Range of values:

OLD_AGE: Old-aged about 60 years old and above

MIDDLE_AGE: middle-aged, about 30-50 years old

YOUTH: youth, about 20-30 years old

Sample: YOUTH

maskKeepbg

Boolean

No

Specifies whether to keep the original image's background. If not set, the original background is kept by default. Range of values:

true: Keep the background unchanged. No need to fill in the bgStyle parameter.

false: Change the background. The bgStyle parameter must be specified.

Sample: true

bgStyle

String

No

Specifies the background style to be generated. When selecting background replacement (maskKeepbg=false), this parameter must be filled in. Currently, four scenes are supported. Range of values:

studio: studio photography

room: room photography

European_street: street photography

beach: beach photography

Sample: studio

count

Number

No

Specifies the desired number of images to be generated. A maximum of four images can be generated per task. If not set, 2 images are generated by default.

Range of value: 1-4

Sample: 2

dimension

Number

No

Specifies the desired size of the images to be generated. The generated images will maintain the original aspect ratio, with the shortest side based on the input value. If not set, the default generated size is 768.

Range of value: 512-2048

Sample: 768

Sample Request

Input limitations:

  • Image formats: JPEG、JPG、PNG、BMP、WEBP

  • Image size: no more than 4 MB

  • Image resolution: The size of input image should be more than 512×512 pixels and less than 3000×3000 pixels.

  • Category: Now the API only supports automatic segmentation and retention for the "clothing" category and does not yet support other specified product categories.

IopClient client = new IopClient(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/ai/virtual/model/generation/batch");
request.addApiParameter("bgStyle", "room");
request.addApiParameter("model", "WHITE");
request.addApiParameter("gender", "FEMALE");
request.addApiParameter("count", "2");
request.addApiParameter("imageStyle", "realPhoto");
request.addApiParameter("imageBase64", "");
request.addApiParameter("imageUrl", "https://ae01.alicdn.com/kf/H873d9e029746449ca21737fcf595b781X.jpg");
request.addApiParameter("maskKeepBg", "true");
request.addApiParameter("dimension", "768");
request.addApiParameter("age", "YOUTH");
IopResponse response = client.execute(request);
System.out.println(response.getBody());
Thread.sleep(10);

Response Parameters

Parameter
Type
Description

requestId

String

A unique request ID used for troubleshooting.

success

Boolean

The status of the returned request, indicating whether the request was successful.

resCode

Number

The returned result code, where 200 indicates success. For detailed error codes, please refer to the error code list.

resMessage

String

The returned request information.

data

Object

The returned JSON result data.

result

Object

The returned result data.

taskId

String

A unique task ID. It is used for subsequent result query requests.

Sample Response

{
  "data": {
    "taskId": "4dcfa662-d5b3-48d5-842e-a87f70ac1522"
  },
  "requestId": "2141111917193839073095037e1893",
  "success": true,
  "resCode": 200,
  "resMessage": "success",
  "code": "0",
  "request_id": "212a664f17193839073127402",
  "_trace_id_": "2141111917193839073095037e1893"
}

Errors

Error Code
Error Message
Description

500

system error

System error.

501

rate limit exceed

The current interface has reached the current limit. Please contact us via navigation bar or email us (aidge_support@service.alibaba.com) to increase the current limit value.

700

invalid input

The format of the input parameters does not meet the requirements, and resMessage will return detailed fields that do not meet the requirements.

801

model failed

Internal call exception, please contact us via navigation bar or email us (aidge_support@service.alibaba.com) for troubleshooting.

1000

content has sensitive data, please try other input

Content has sensitive data and cannot be handled now. Please try other input.

1001

content control failed, please retry

Content risk failed, please try other input. If an error persists,please contact us via navigation bar or email us (aidge_support@service.alibaba.com) for troubleshooting.

1002

content risk filter failed, please contact us

Content risk failed, please ccontact us via navigation bar or email us (aidge_support@service.alibaba.com).

Last updated