File size: 3,872 Bytes
475e066
 
 
 
 
 
 
 
 
 
 
9c5e178
 
475e066
 
9c5e178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475e066
9c5e178
 
 
475e066
9c5e178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475e066
 
 
9c5e178
 
 
 
 
 
 
475e066
 
 
9c5e178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475e066
 
 
9c5e178
 
 
 
 
 
 
 
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
---
title: ClothQuill - AI Clothing Inpainting
emoji: πŸ‘•
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.25.1
app_file: app.py
pinned: false
---

<div align="center">

# ClothQuill - AI Clothing Inpainting

[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/bismay/ClothQuill)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)

🎨 An AI-powered tool for seamlessly editing and modifying clothing in images using state-of-the-art deep learning models.

[Demo](#demo) β€’ [Features](#features) β€’ [Installation](#installation) β€’ [Usage](#usage) β€’ [Examples](#examples) β€’ [Technical Details](#technical-details)

</div>

## Demo

ClothQuill is available as a Hugging Face Space! Try it out here: [ClothQuill Demo](https://huggingface.co/spaces/bismay/ClothQuill)

## Features

- 🎯 **Precise Clothing Detection**: Automatically identifies and segments different clothing items
- 🎨 **Interactive Selection**: Choose specific clothing parts to modify
- πŸ”„ **Multiple Variations**: Generate multiple inpainting results for each prompt
- πŸŽ›οΈ **Adjustable Controls**: Fine-tune mask dilation for better blending
- πŸ–ΌοΈ **High-Quality Output**: Maintains image quality with advanced upscaling
- πŸš€ **Real-time Preview**: See segmentation masks and selected regions in real-time

## Installation

```bash
# Clone the repository
git clone https://huggingface.co/spaces/bismay/ClothQuill
cd ClothQuill

# Install dependencies
pip install -r requirements.txt

# Download required models (will be downloaded automatically on first run)
python download_models.py
```

## Usage

1. **Start the Application**
   ```bash
   python app.py
   ```

2. **Using the Interface**
   - Upload an image containing a person
   - The app will automatically detect clothing regions
   - Select which parts of the clothing you want to modify
   - Adjust the mask dilation if needed
   - Enter a prompt describing the desired clothing
   - Click "Generate" to create multiple variations

3. **Advanced Options**
   - Use the dilation slider to control the modification area
   - Select multiple clothing parts for simultaneous editing
   - Preview the segmentation mask before generating

## Examples

Here are some example prompts and their use cases:

- πŸ§₯ **Outerwear**: "A stylish black leather jacket with silver zippers"
- πŸ‘” **Formal**: "A navy blue pinstripe suit with a white dress shirt"
- πŸ‘• **Casual**: "A comfortable gray hoodie with white drawstrings"
- πŸ‘— **Dresses**: "A flowing red summer dress with floral patterns"
- πŸ‘– **Pants**: "Dark blue distressed jeans with a vintage wash"

## Technical Details

ClothQuill combines multiple state-of-the-art models:

- **Segmentation**: [SegFormer](https://huggingface.co/mattmdjaga/segformer_b2_clothes) for precise clothing detection
- **Inpainting**: [Stable Diffusion 2.0](https://huggingface.co/stabilityai/stable-diffusion-2-inpainting) for high-quality image generation
- **Upscaling**: [RealESRGAN](https://github.com/xinntao/Real-ESRGAN) for maintaining image quality

### Model Architecture

```
Input Image β†’ SegFormer (Segmentation) β†’ User Selection β†’ 
Mask Generation β†’ Stable Diffusion (Inpainting) β†’ 
RealESRGAN (Upscaling) β†’ Final Output
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Thanks to the Hugging Face team for hosting the demo
- Stable Diffusion by Stability AI
- SegFormer implementation by mattmdjaga
- RealESRGAN by xinntao