File size: 3,034 Bytes
d8ccdd3
 
 
 
 
 
 
 
 
 
cd18701
11baa78
cd18701
11baa78
cd18701
11baa78
cd18701
 
 
 
 
11baa78
cd18701
11baa78
cd18701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
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

1. Clone the repository:
```bash
git clone <repository-url>
cd virtual-tryon
```

2. Create a virtual environment and activate it:
```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

3. Install dependencies:
```bash
pip install -r requirements.txt
```

### Docker Deployment

1. Build and run using Docker Compose:
```bash
docker-compose up --build
```

The application will be available at http://localhost:8000

## Usage

### Web Interface (Shiny)

1. Start the application:
```bash
python app.py --shiny
```

2. Open your web browser and navigate to http://localhost:8000

3. Upload a garment image with transparent background

4. Click "Start Try-On" to begin the virtual try-on session

5. 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)

1. Start the application:
```bash
python app.py --tkinter
```

2. Use the GUI controls to upload a garment and adjust parameters

### Command Line Mode

1. Run with a specific garment:
```bash
python app.py --garment path/to/garment.png
```

## Directory Structure

- `models/`: Directory for storing OpenPose models
- `temp/`: Directory for temporary files
- `app.py`: Main application file
- `requirements.txt`: Python dependencies
- `Dockerfile`: Container configuration
- `docker-compose.yml`: Docker Compose configuration

## Troubleshooting

1. 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

2. 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

3. 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.