This API allows users to virtually try on clothing. The system takes two images as input:
- Person Image – The image of the person who wants to try on clothes.
- Clothing Image – Either an image of a standalone piece of clothing or a person wearing the clothing.
- Remove Background – The backgrounds of both images are removed.
- Head Cropping (if applicable) – If the clothing image is of a person, the head is cropped.
- Virtual Try-On – The processed images are sent to the Try-On API to generate the final output, showing the person wearing the clothing.
Here are some example results from our Virtual Try-On API:
Left: Person Image | Right: Clothing Image
Target clothing item used in the try-on
Final Result: Person wearing the selected clothing item
Before installing dependencies, create a virtual environment:
python -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activateOnce the virtual environment is activated, install the required dependencies:
pip install -r requirements.txtRedis is required for Celery task management. Run:
redis-serverRun the FastAPI application using:
uvicorn main:app --reloadRun the Celery worker to process background tasks:
PYTHONPATH=$(pwd) celery -A tasks worker --loglevel=info --pool=threadsEndpoint:
POST /process-two-images/Description:
Uploads two images and starts processing them.
Request Example (Multipart Form-Data):
{
"base_image": <person_image.jpg>,
"target_image": <clothing_image.jpg>
}Response:
{
"task_id": "12345abcde",
"message": "Processing started"
}Endpoint:
GET /task-status/{task_id}Description:
Checks the processing status of an image processing task.
Response Example (In Progress):
{
"task_id": "12345abcde",
"status": "PENDING",
"result": null
}Response Example (Completed):
{
"task_id": "12345abcde",
"status": "SUCCESS",
"result": {
"images": [
{"url": "https://yourserver.com/segmented_image.jpg"}
]
}
}- ✅ Accurate clothing placement
- ✅ Natural body pose preservation
- ✅ High-quality image output
- ✅ Realistic fabric rendering
- ✅ Seamless integration with body shape
For any questions or support, please open an issue in this repository.