API For Virtual Try-on
About 1 min
API For Virtual Try-on
Virtual Try-on Describe
By simply uploading a single photo of themselves and a photo of the clothing item, users can see an image of themselves wearing the clothes.
Virtual try-on technology allows users to preview how clothes will look on them while shopping online, enhancing the shopping experience and reducing return rates.
Considerations
Before using the API, make sure you have obtained the API key. Refer to the link below for instructions on how to obtain it. API For API Key Settings
All generated images will be automatically deleted after 24 hours. Please make sure to save the images you need to your local storage in a timely manner.
Credits Consumption
Normal mode: each picture needs 8 credits.
Header Attributes
Parameter | Description |
---|---|
Authorization | Your API Key used for request authorization. |
Create Job
Request Url
--request POST https://developer.vmodel.ai/api/vmodel/v1/ai-virtual-try-on/create-job
Body Attributes
Parameter | Type | Required | Description |
---|---|---|---|
clothes_image | file[binary] | true | input_image garment pictures, only upload one at a time, should match the category, can be product pictures, or even someone's photo |
custom_model | file[binary] | true | input_image Model image, upload one at a time, with the best size of 3:4 |
clothes_type | string | true | Category of garment It needs to be one of the three options, "upper_body","lower_body","dresses" |
prompt | string | false | Prompt. Example: 'A black short skirt shorter than the knee'. |
forced_cutting | bool | false | Use cropping? (check this if your image is not 3:4) |
demo
import requests
url = "https://developer.vmodel.ai/api/vmodel/v1/ai-virtual-try-on/create-job"
payload = {
'clothes_type': 'upper_body',
'forced_cutting': True,
'prompt': 'your prompt'
}
files=[
('clothes_image',('demo1.JPG',open('demo1.png','rb'),'image/png')),
('custom_model',('demo2.jpg',open('demo2.png','rb'),'image/png'))
]
headers = {
'Authorization': 'your token',
'accept': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
Response
{
"code": 100000,
"result": {
"job_id": "your-job-id"
},
"message": {
"en": "Request Success."
}
}
Fetch Job
Request Url
--request GET https://developer.vmodel.ai/api/vmodel/v1/ai-virtual-try-on/get-job/your-job-id
Body Attributes
Parameter | Description |
---|---|
job_id | job_id returned by create task |
demo
import requests
url = 'https://developer.vmodel.ai/api/vmodel/v1/ai-virtual-try-on/get-job/your-job-id'
headers = {
'accept': 'application/json',
'Authorization': 'your token',
}
response = requests.get(url, headers=headers)
print(response.json()) # Print the response content
Response
{
"code": 100000,
"result": {
"output_image_url": [
"your-output-image.png"
],
"input_image_url": [
"https://image.remaker.ai/.../your-input-clothes-image.png",
"https://image.remaker.ai/.../your-input-model-image.png"
],
"job_id": "your-job-id",
"message": ""
},
"message": {
"en": "Image generated successfully."
}
}
Response Code
Code | Description |
---|---|
100000 | Request Success. |
200000 | Request Failure. |
300101 | system error. |
300102 | Image generation in progress. |
300104 | Image generated failed. |
400101 | Insufficient credits. |
400303 | Token ERROR. |
400501 | Task Not Found |