Spaces:
Build error
Build error
metadata
title: Virtual Try-On App
emoji: 👕
colorFrom: blue
colorTo: green
sdk: docker
app_port: 8000
pinned: false
Advanced Virtual Try-On
A web-based virtual try-on application that allows users to try on clothing virtually using their webcam. Built with Python, OpenCV, and Shiny.
Features
- Real-time virtual try-on using webcam
- Support for transparent background garment images
- Adjustable garment fitting parameters
- Multiple UI modes (Shiny web interface, Tkinter desktop app)
- Docker support for easy deployment
Prerequisites
- Python 3.9 or higher
- Docker and Docker Compose (for containerized deployment)
- Webcam
- OpenPose models (will be downloaded automatically on first run)
Installation
Local Development
- Clone the repository:
git clone <repository-url>
cd virtual-tryon
- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Docker Deployment
- Build and run using Docker Compose:
docker-compose up --build
The application will be available at http://localhost:8000
Usage
Web Interface (Shiny)
- Start the application:
python app.py --shiny
Open your web browser and navigate to http://localhost:8000
Upload a garment image with transparent background
Click "Start Try-On" to begin the virtual try-on session
Adjust the garment fit using the sliders:
- Width Scale: Adjust the width of the garment
- Height Scale: Adjust the height of the garment
- Collar Position: Adjust the vertical position of the garment
- Show Skeleton: Toggle the display of pose estimation skeleton
Desktop Application (Tkinter)
- Start the application:
python app.py --tkinter
- Use the GUI controls to upload a garment and adjust parameters
Command Line Mode
- Run with a specific garment:
python app.py --garment path/to/garment.png
Directory Structure
models/: Directory for storing OpenPose modelstemp/: Directory for temporary filesapp.py: Main application filerequirements.txt: Python dependenciesDockerfile: Container configurationdocker-compose.yml: Docker Compose configuration
Troubleshooting
Webcam not detected:
- Ensure your webcam is properly connected
- Check if the webcam is being used by another application
- For Docker deployment, ensure proper device access is configured
Garment not displaying correctly:
- Use images with transparent backgrounds (PNG format recommended)
- Ensure the garment image is not too large or too small
- Try adjusting the width and height scales
Performance issues:
- Reduce the camera resolution
- Close other resource-intensive applications
- For Docker deployment, ensure proper resource allocation
License
This project is licensed under the MIT License - see the LICENSE file for details.