Customized mask
In the Quick start tutorial, you have shown how to generate AI fashion model with auto generated mask. In this tutorial, you will learn how to generate AI fashion model with customized mask.
Let's say you have an image of a female model and you just want to keep the skirt during the model generation process as shown below.
Now, let's see how to generate AI fashion model with customized mask.
Prepare the mask
In this tutorial, you will use the Segment Clothes API to generate the mask for the skirt. The Segment Clothes API is a powerful tool that can be used to generate masks for clothes in images. It's currently supports the following types of mask:
- Tagged mask: This type of mask contains only the target areas associated with a specified tag. For example, a mask with the coat tag will solely contain the coat areas.
- Unified mask: This type of mask merges target areas into one mask, representing them using a specified color model. For example, a mask featuring the white color model will depict all target areas in white.
To generate the mask for the skirt, you will use the Segment Clothes API to genereate a unified mask with the tag skirt
. The request body for the Segment Clothes API
is shown below:
{
"image": "https://gcs-airbrush.mr.pixocial.com/f5e6df0c59ea56b1863893b6f9ea2a11.png",
"unifiedMasks": [
{
"tags": ["skirt"],
"maskColorModel": "black-white",
"maskDataType": "url"
}
]
}
Let's make a POST request to the Segment Clothes API with the above request body in different programming languages.
curl -X POST \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://gcs-airbrush.mr.pixocial.com/f5e6df0c59ea56b1863893b6f9ea2a11.png",
"taggedMasks": [
{
"tag": "skirt",
"maskColorModel": "black-white",
"maskDataType": "url"
}
]
}' \
https://open.vmake.ai/api/v2/image/clothes-segmentation
The API will return the response body as shown below:
{
"code": 0,
"message": "Success",
"data": {
"unifiedMasks": [
{
"tags": [
"skirt"
],
"mask": "https://gcs-airbrush.mr.pixocial.com/99eec3e24edaff14fe540ec4389741ee.png"
}
]
}
}
As you can see, the API has successfully generated the mask for the skirt.
Generate models
Now that you have the mask for the skirt, you can follow the steps described in Quick start to generate model images. The only difference is that you need to modify the request parameters for creating an asynchronous generation task, as shown below:
{
"image": "https://gcs-airbrush.mr.pixocial.com/f5e6df0c59ea56b1863893b6f9ea2a11.png",
"mask": "CUSTOM_MASK_URL_RETURNS_BY_SEGMENT_CLOTHES_API",
"modelId": "002",
"sceneType": "preset",
"sceneId": "035"
}
mask
: The URL of the mask to be used. In this case, it is the URL of the mask for the skirt.
Let's make some changes to the different language implementations in the Quick start tutorial to generate the model with the customized mask.
curl -X POST \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://gcs-airbrush.mr.pixocial.com/f5e6df0c59ea56b1863893b6f9ea2a11.png",
"mask": "CUSTOM_MASK_URL_RETURNS_BY_SEGMENT_CLOTHES_API",
"modelId": "002",
"sceneType": "preset",
"sceneId": "035"
}' \
https://open.vmake.ai/api/v4/image/ai-fashion-model/clothing-tasks
In the code snippet above, you first create an asynchronous task with specified image URL and mask tag "skirt". Then, you check the task status in fixed intervals until the task is completed. Finally, you print the download URLs of the generated images.
Note: Since AI fashion model generation is a time-consuming process, you may need to wait for a while until the task is completed.
View the results
After the task completed successfully, you can view the generated images by using the download URLs in the results. Below shows the generated images with different scenes.
Congratulations! You have successfully generated AI fashion models with a different scene but keeping the skirt the same using the Vmake AI Fashion Model API.
Conclusion
In this tutorial, you have learned how to create an asynchronous task to generate AI fashion models with customized mask and check the task status until the task is completed. You have also seen how to view the generated images with different scenes. In the next tutorial, you will learn how to customized generated model details using the Vmake AI Fashion Model API.