83 lines
2.7 KiB
Markdown
83 lines
2.7 KiB
Markdown
# Garment photo cleaner
|
|
|
|
CLI tool that cleans up second-hand clothing photos for marketplace listings (Vinted, eBay, Depop). It removes fabric wrinkles, puts the garment on a studio backdrop (warm beige or bright white), and preserves shapes, colors, prints, buttons, and defects.
|
|
|
|
Uses OpenRouter's Image API with `meta/muse-image`.
|
|
|
|
## Requirements
|
|
|
|
- Python 3.9 or higher
|
|
- OpenRouter API key with image generation credits
|
|
|
|
Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
Set your API key:
|
|
|
|
```bash
|
|
export OPENROUTER_API_KEY="sk-or-v1-..."
|
|
```
|
|
|
|
## Usage
|
|
|
|
Basic run with default soft beige background:
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg
|
|
```
|
|
|
|
Output saves next to the source photo as `shirt_clean.jpg`.
|
|
|
|
### Options
|
|
|
|
Select a white background:
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg --bg white
|
|
```
|
|
|
|
Custom output path:
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg -o /path/to/listing_photo.jpg
|
|
```
|
|
|
|
Custom background description:
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg --bg "Soft cool grey studio background, even lighting"
|
|
```
|
|
|
|
Keep native model resolution (skip automatic upscale to input dimensions):
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg --no-restore-res
|
|
```
|
|
|
|
Override the model:
|
|
|
|
```bash
|
|
python3 unwrap_clothes.py shirt.jpg --model meta/muse-image
|
|
```
|
|
|
|
## Why meta/muse-image is the default
|
|
|
|
Other image models on OpenRouter run into policy or cost issues on second-hand clothing photos:
|
|
|
|
1. `openai/gpt-5-image-mini`: OpenAI's input image filter rejects photos with licensed character artwork (such as Winnie the Pooh, Disney, or cartoon prints), returning HTTP 400 safety errors regardless of prompt phrasing.
|
|
2. `qwen/qwen-image-3`: Alibaba moderation frequently blocks full garment photos, and Qwen 3 Pro costs roughly $0.08 per image.
|
|
3. `meta/muse-image`: Accepts photos of branded and character clothing, costs $0.01 per image, and finishes in 15 to 25 seconds.
|
|
|
|
## Resolution handling
|
|
|
|
`meta/muse-image` caps output at roughly 1.3 to 1.8 MP (for example, 1376x1824) regardless of the size parameters passed to the API.
|
|
|
|
To avoid downsized uploads on marketplaces that expect high-resolution smartphone photos (such as 3024x4032), the script automatically resizes the generated image back to the source file's exact dimensions using Lanczos interpolation. This preserves the aspect ratio and frame size of the original photo.
|
|
|
|
## Known limitations
|
|
|
|
- Garments that are physically folded or bunched over themselves in the photo remain bunched. Generative editing smooths surface wrinkles, but will not unfold fabric that covers other parts of the garment.
|
|
- Small text on labels and complex repeating patterns can drift slightly from the original during generation.
|