An AI-powered virtual try-on application that uses ComfyUI backend with IDM-VTON for realistic garment visualization.
- Virtual Try-On: Realistic garment fitting using IDM-VTON AI model
- Color Harmony Analysis: Automatic color matching score using K-Means clustering
- Real-time Progress: WebSocket-based live progress tracking
- Debug Mode: Visual mask preview for troubleshooting
- Modern UI: Clean, minimalist interface with maximum readability
- Multiple Output Support: Tries multiple methods to retrieve results (API, direct file access, newest file)
Upload a model photo and a garment photo, select category, and get:
- Virtual try-on result
- Color harmony score (0-100)
- Generated mask (debug view)
- Python 3.8+
- ComfyUI with IDM-VTON nodes installed
- Required models:
- SAM (Segment Anything Model)
- GroundingDINO
- DensePose
- IDM-VTON pipeline
git clone https://github.com/YOUR_USERNAME/virtual-tryon-studio.git
cd virtual-tryon-studiopip install -r requirements.txtEdit app.py and update these paths:
COMFYUI_INPUT_PATH = "/path/to/ComfyUI/input"
COMFYUI_OUTPUT_PATH = "/path/to/ComfyUI/output"
COMFYUI_TEMP_PATH = "/path/to/ComfyUI/temp"cd /path/to/ComfyUI
python main.pystreamlit run app.pyOpen your browser at http://localhost:8501
-
Upload Images
- Model photo (person wearing simple clothes)
- Garment photo (clothing item on plain background)
-
Configure
- Select category: Upper Body or Lower Body
- Enter garment description (e.g., "Red polo shirt")
-
Try On
- Click "Try On" button
- Wait ~15-20 minutes for processing
- View real-time progress
-
Results
- Virtual try-on image
- Color harmony score
- Download result
Use the sidebar test feature to quickly analyze any image's color harmony without running the full workflow.
- Image Loading: Load model and garment images
- Preprocessing: Resize images to 624x880
- Segmentation: Use GroundingDINO + SAM for mask generation
- Pose Detection: Extract pose information with DensePose
- Try-On: Apply IDM-VTON with detected pose and mask
- Color Analysis: K-Means clustering for dominant color extraction
- Splits image horizontally (upper/lower body)
- Extracts dominant colors using K-Means (n=5)
- Converts to HSV color space
- Calculates harmony score based on:
- Complementary colors (150Β°+ hue diff): 88-98 points
- Analogous colors (<30Β° hue diff): 80-92 points
- Neutral colors (low saturation): 85-96 points
- Other combinations: 55-85 points
Currently hardcoded for testing:
- Mask prompt: "shirt"
- Threshold: 0.3
To disable debug mode, edit update_workflow() function.
User Input β Streamlit UI β ComfyUI API β Workflow Execution
β β
File Upload WebSocket Progress
β β
Color Analysis β Output Retrieval β Result
- Processing time: ~15-20 minutes (depends on hardware)
- GPU recommended (CUDA support)
- RAM: Minimum 8GB, recommended 16GB+
- Check ComfyUI is running (
http://127.0.0.1:8188) - Verify output/temp folder paths
- Check disk space
- View debug mask to verify mask generation
- Threshold is set to 0.3 (debug mode)
- Try adjusting threshold in workflow template
- Check model is properly visible in input image
- Ensure GPU is being used
- Close other GPU-intensive applications
- Check ComfyUI logs for errors
Edit WORKFLOW_TEMPLATE in app.py:
- Adjust image size (default: 624x880)
- Change inference steps (default: 20)
- Modify guidance scale (default: 2.0)
- Update seed for reproducibility
Edit CUSTOM_CSS in app.py for styling changes.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- ComfyUI - Powerful node-based UI
- IDM-VTON - Virtual try-on model
- SAM - Segmentation model
- GroundingDINO - Object detection
For questions or feedback, please open an issue on GitHub.
Made with β€οΈ using Streamlit and ComfyUI