CoolFace
Apppublic

hauteuar/Dress_swap_beta

sourceHugging Facemitupdated 1y agoView on Hugging Face
3likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

๐Ÿงฅ Virtual Try-On with Gradio for Hugging Face Spaces

This is a CPU-compatible virtual try-on application that allows users to see themselves wearing different garments. The app uses a simplified version of Stable Diffusion with inpainting to create realistic try-on results, optimized to run without GPU requirements.

Features

  • โ€”Upload your own photo
  • โ€”Upload garment images to try on
  • โ€”Simple interface built with Gradio
  • โ€”CPU-optimized for Hugging Face Spaces deployment
  • โ€”Automatic torso segmentation

How It Works

  1. 1.Image Upload: Users upload their photo and a garment image
  2. 2.Body Segmentation: The system identifies the torso region
  3. 3.Virtual Try-On: Using Stable Diffusion's inpainting capabilities, the system replaces the torso region with the garment
  4. 4.Result Display: The final try-on result is shown to the user

Deployment Instructions

Option 1: Deploy to Hugging Face Spaces

  1. 1.Create a new Space on Hugging Face Spaces
  2. 2.Select Gradio as the SDK
  3. 3.Upload these files to your Space repository
  4. 4.The app will automatically build and deploy

Option 2: Run Locally

bash
# Clone the repository
git clone [your-repo-url]
cd [your-repo-name]

# Install dependencies
pip install -r requirements.txt

# Run the app
python app.py

Optimizations

This version has been specifically optimized for CPU environments:

  • โ€”Uses a smaller Stable Diffusion 1.5 model instead of SDXL
  • โ€”Implements efficient CPU offloading
  • โ€”Reduces the number of inference steps
  • โ€”Uses simplified segmentation techniques
  • โ€”Provides clear expectations about processing time

Integration with Websites

To embed this app in your website:

html
<iframe
  src="https://huggingface.co/spaces/your-username/your-space-name"
  frameborder="0"
  width="850"
  height="600"
></iframe>

Limitations

  • โ€”Processing time on CPU is significantly longer (5-10 minutes per image)
  • โ€”Segmentation is simplified and may not be as precise
  • โ€”Image quality is reduced compared to GPU versions
  • โ€”Complex garments may not transfer as accurately

Future Improvements

  • โ€”Add pre-trained body segmentation for better accuracy
  • โ€”Implement caching for faster results
  • โ€”Add garment color customization options
  • โ€”Support for multiple garment try-on simultaneously

Credits

This implementation is based on Stable Diffusion by Runway and Stability AI, with optimizations for CPU performance and Gradio interface.