ClothIron / SETUP.md
Mihir Mithani
Initial commit: AI Virtual Garment Ironing System
c7159bc
|
Raw History Blame Contribute Delete
2.89 kB

A newer version of the Gradio SDK is available: 6.32.0

Upgrade

Setup & Run Guide

1. PyCharm Setup

Clone / open project

  1. Open PyCharm β†’ File β†’ Open β†’ select the garment_ironing/ folder
  2. PyCharm will detect requirements.txt automatically

Create virtual environment

In PyCharm terminal:

python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

pip install --upgrade pip
pip install -r requirements.txt

Run configuration

  1. Run β†’ Edit Configurations β†’ + β†’ Python
  2. Script: app.py
  3. Working directory: project root
  4. Click Run or press Shift+F10

The app opens at http://localhost:7860


2. Generate example images (first run only)

python create_example_assets.py

3. Train custom wrinkle model (optional)

# Prepare your dataset in data/train/images, data/train/masks, data/val/...
python train_wrinkle_model.py --data_dir data --epochs 50 --batch_size 8

4. Publish to HuggingFace Spaces

Install HF CLI

pip install huggingface_hub
huggingface-cli login   # paste your HF token

Create a new Space

huggingface-cli repo create garment-ironing --type space --space_sdk gradio

Push all files

cd garment_ironing
git init
git add .
git commit -m "initial commit"
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/garment-ironing
git push -u origin main

HuggingFace will automatically install requirements.txt and run app.py.


5. Environment variables (optional secrets)

If you want to use private HF model weights, set in HF Space secrets:

  • HF_TOKEN β€” your HuggingFace token

6. GPU vs CPU behaviour

Hardware Ironing method Speed
NVIDIA GPU (β‰₯8 GB VRAM) Stable Diffusion inpainting ~10–30 s/image
CPU only Classical bilateral + guided filter ~3–8 s/image

HuggingFace Spaces free tier runs on CPU. Upgrade to a GPU Space for SD inpainting.


7. File structure

garment_ironing/
β”œβ”€β”€ app.py                      ← Gradio UI + entry point
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md                   ← HuggingFace Spaces config + docs
β”œβ”€β”€ train_wrinkle_model.py      ← Training script (run locally)
β”œβ”€β”€ create_example_assets.py    ← Generate placeholder example images
β”œβ”€β”€ assets/                     ← Example images for the UI
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ segmentation.py         ← SegFormer garment segmenter
β”‚   β”œβ”€β”€ wrinkle_detector.py     ← Multi-scale wrinkle detection
β”‚   └── ironing_pipeline.py     ← Classical + SD inpainting ironer
└── utils/
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ image_utils.py          ← Resize, compare, overlay helpers
    └── analysis.py             ← Wrinkle scoring + report generation