{"id":29035955,"url":"https://github.com/arnavballincode/idm_vton_api_implementation","last_synced_at":"2025-06-26T12:36:29.820Z","repository":{"id":299856298,"uuid":"1002862058","full_name":"ArnavBallinCode/IDM_VTON_API_IMPLEMENTATION","owner":"ArnavBallinCode","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-18T16:29:22.000Z","size":8769,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-18T17:35:36.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ArnavBallinCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-16T08:59:48.000Z","updated_at":"2025-06-18T16:29:25.000Z","dependencies_parsed_at":"2025-06-18T17:48:40.101Z","dependency_job_id":null,"html_url":"https://github.com/ArnavBallinCode/IDM_VTON_API_IMPLEMENTATION","commit_stats":null,"previous_names":["arnavballincode/idm_vton_api_implementation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ArnavBallinCode/IDM_VTON_API_IMPLEMENTATION","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavBallinCode%2FIDM_VTON_API_IMPLEMENTATION","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavBallinCode%2FIDM_VTON_API_IMPLEMENTATION/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavBallinCode%2FIDM_VTON_API_IMPLEMENTATION/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavBallinCode%2FIDM_VTON_API_IMPLEMENTATION/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArnavBallinCode","download_url":"https://codeload.github.com/ArnavBallinCode/IDM_VTON_API_IMPLEMENTATION/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArnavBallinCode%2FIDM_VTON_API_IMPLEMENTATION/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262068860,"owners_count":23253879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-26T12:36:29.483Z","updated_at":"2025-06-26T12:36:29.811Z","avatar_url":"https://github.com/ArnavBallinCode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IDM-VTON Virtual Try-On\n\n![Python](https://img.shields.io/badge/Python-3.7+-blue.svg)\n![HuggingFace](https://img.shields.io/badge/🤗-Hugging%20Face-yellow.svg)\n![AI](https://img.shields.io/badge/AI-Diffusion%20Models-green.svg)\n![License](https://img.shields.io/badge/License-MIT-red.svg)\n\nA Python script for virtual try-on using the IDM-VTON (Improving Diffusion Models for Authentic Virtual Try-on in the Wild) model via Hugging Face Spaces API.\n\n\u003e 🚀 **Try on any garment on any person with AI-powered precision!**\n\n## 🎭 Examples \u0026 Results\n\nSee the magic of AI-powered virtual try-on! Here are real results from our example images:\n\n### Example Results Table\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth width=\"25%\"\u003e👤 Person\u003c/th\u003e\n\u003cth width=\"25%\"\u003e👕 Garment\u003c/th\u003e\n\u003cth width=\"25%\"\u003e✨ Result\u003c/th\u003e\n\u003cth width=\"25%\"\u003e📝 Description\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/person_images/Arnav_A.jpg\" width=\"150\" alt=\"Arnav\"\u003e\u003cbr\u003e\n\u003cem\u003eArnav A.\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/garment_images/gucci upper.jpg\" width=\"150\" alt=\"Gucci Upper\"\u003e\u003cbr\u003e\n\u003cem\u003eGucci Upper\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/results/result_tryon_arnav.png\" width=\"150\" alt=\"Result\"\u003e\u003cbr\u003e\n\u003cem\u003eVirtual Try-On\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cstrong\u003eYoung Male + Luxury Garment\u003c/strong\u003e\u003cbr\u003e\nPerfect fit demonstration with premium Gucci upper garment on young male subject\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/person_images/korean girl.png\" width=\"150\" alt=\"Korean Girl\"\u003e\u003cbr\u003e\n\u003cem\u003eKorean Girl\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/garment_images/gucci upper.jpg\" width=\"150\" alt=\"Gucci Upper\"\u003e\u003cbr\u003e\n\u003cem\u003eGucci Upper\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/results/result_tryon.png\" width=\"150\" alt=\"Result\"\u003e\u003cbr\u003e\n\u003cem\u003eVirtual Try-On\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cstrong\u003eFemale + Clean Background\u003c/strong\u003e\u003cbr\u003e\nExcellent garment transfer with clean background preservation and natural fitting\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/person_images/will_smith.jpg\" width=\"150\" alt=\"Will Smith\"\u003e\u003cbr\u003e\n\u003cem\u003eWill Smith\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n\u003cimg src=\"examples/garment_images/upper_2.jpg\" width=\"150\" alt=\"Alternative Upper\"\u003e\u003cbr\u003e\n\u003cem\u003eAlternative Upper\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd align=\"center\"\u003e\n⚡ \u003cstrong\u003eGenerate Now!\u003c/strong\u003e\u003cbr\u003e\n\u003ccode\u003epython run_examples.py\u003c/code\u003e\u003cbr\u003e\n\u003cem\u003eOption 3\u003c/em\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cstrong\u003eCelebrity + Alternative Style\u003c/strong\u003e\u003cbr\u003e\nProfessional photo with alternative garment - perfect for formal wear demonstration\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### Available Assets\n\n**👤 Person Images:**\n- `Arnav_A.jpg` - Young male, front-facing, ideal for casual/formal wear\n- `korean girl.png` - Female model, clean background, perfect for fashion items\n- `will_smith.jpg` - Male celebrity, professional photo, great for formal wear\n- `Full Man.jpg` - **NEW!** Full body male model, perfect for complete outfits\n\n**👕 Garment Images:**\n- `gucci upper.jpg` - Premium luxury brand upper garment\n- `upper_2.jpg` - Alternative stylish upper garment option\n- `upper_3.jpg` - **NEW!** Red checkered shirt, casual style\n- `pants.jpg` - **NEW!** Dark cargo pants, lower body garment\n\n### New Combinations Available! 🆕\n✨ **Upper Body**: Red checkered shirt on any person  \n✨ **Lower Body**: Dark cargo pants (works with virtual-try-on!)  \n✨ **Full Body**: Complete outfit combinations with Full Man model  \n\n### Quick Demo\n```bash\n# Try it yourself in 30 seconds!\npython two_step_pipeline.py\n# Choose option 1-8 or 'all' to see the magic ✨\n```\n\n## Overview\n\nThis project allows you to virtually try on garments on person images using state-of-the-art diffusion models. The script uses your private Hugging Face Pro space for faster processing and no rate limits.\n\n## Features\n\n- ✨ Virtual garment try-on using IDM-VTON model\n- 🚀 Private Hugging Face Pro space integration\n- 🔒 Secure token-based authentication\n- 🎨 High-quality diffusion-based results\n- 📸 Support for various image formats\n\n## Prerequisites\n\n- Python 3.7+\n- Hugging Face Pro account\n- Conda environment (recommended)\n\n## Installation\n\n1. **Clone or download this repository**\n\n2. **Create and activate conda environment:**\n   ```bash\n   conda create -n viton python=3.10\n   conda activate viton\n   ```\n\n3. **Install required packages:**\n   ```bash\n   pip install gradio_client huggingface_hub python-dotenv\n   ```\n\n4. **Install Hugging Face CLI (optional but recommended):**\n   ```bash\n   pip install --upgrade huggingface_hub[cli]\n   ```\n\n## Setup\n\n### 1. Hugging Face Account \u0026 CLI Setup\n\n#### **Step 1: Create HF Pro Account**\n1. Sign up at [Hugging Face](https://huggingface.co/)\n2. Upgrade to [HF Pro](https://huggingface.co/pricing) for private spaces and priority access\n\n#### **Step 2: Install and Login to HF CLI**\n```bash\n# Install HF CLI\npip install --upgrade huggingface_hub[cli]\n\n# Login to HF CLI (this will prompt for your token)\nhuggingface-cli login\n\n# Verify login\nhuggingface-cli whoami\n```\n\n#### **Step 3: Alternative - Manual Token Setup**\nIf you prefer not to use HF CLI login:\n\n1. **Get your token:**\n   ```bash\n   # Go to: https://huggingface.co/settings/tokens\n   # Create new token with \"Read\" or \"Write\" access\n   ```\n\n2. **Set up token (choose one method):**\n\n   **Method A: Using .env file (recommended for development)**\n   ```bash\n   # Copy the example file\n   cp .env.example .env\n   \n   # Edit .env file and add your token\n   echo \"HUGGINGFACE_TOKEN=hf_your_actual_token_here\" \u003e .env\n   ```\n\n   **Method B: Environment variable (for production)**\n   ```bash\n   # Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)\n   export HUGGINGFACE_TOKEN=\"hf_your_token_here\"\n   \n   # Or set for current session only\n   export HUGGINGFACE_TOKEN=\"hf_your_token_here\"\n   ```\n\n   **Method C: Using HF CLI to set token**\n   ```bash\n   # Set token using CLI\n   huggingface-cli login --token hf_your_token_here\n   ```\n\n### 2. Private Space Setup \u0026 Configuration\n\n#### **Step 1: Duplicate the Original Space**\n\n**Option A: Using HF CLI (Recommended)**\n```bash\n# Duplicate the space to your account\nhuggingface-cli repo duplicate yisol/IDM-VTON your_username/IDM-VTON --type space\n\n# Or with specific settings\nhuggingface-cli repo duplicate yisol/IDM-VTON your_username/IDM-VTON \\\n  --type space \\\n  --private \\\n  --exist-ok\n```\n\n**Option B: Using Web Interface**\n1. Go to [yisol/IDM-VTON](https://huggingface.co/spaces/yisol/IDM-VTON)\n2. Click \"⋯\" menu → \"Duplicate this Space\"\n3. Set your space name: `your_username/IDM-VTON`\n4. ✅ Check \"Private\" if you want it private\n5. Click \"Duplicate Space\"\n\n#### **Step 2: Configure Your Private Space**\n\n1. **Wait for space to build** (may take 5-10 minutes)\n2. **Check space status:**\n   ```bash\n   # Check if your space is running\n   huggingface-cli api info your_username/IDM-VTON --repo-type space\n   ```\n\n3. **Test space accessibility:**\n   ```bash\n   # Test API endpoint\n   curl -H \"Authorization: Bearer $HUGGINGFACE_TOKEN\" \\\n        https://huggingface.co/api/spaces/your_username/IDM-VTON\n   ```\n\n#### **Step 3: Space Management Commands**\n\n```bash\n# View your spaces\nhuggingface-cli api list-repos --type space\n\n# Check space info\nhuggingface-cli api info your_username/IDM-VTON --repo-type space\n\n# Restart space if needed\nhuggingface-cli api restart-space your_username/IDM-VTON\n\n# Make space private/public\nhuggingface-cli api update-repo-visibility your_username/IDM-VTON \\\n  --repo-type space --private\n\n# Delete space (be careful!)\n# huggingface-cli api delete-repo your_username/IDM-VTON --repo-type space\n```\n\n### 3. Token Permissions \u0026 Security\n\n#### **Required Token Permissions:**\n- **Read**: For accessing public spaces and models ✅\n- **Write**: For managing your own spaces and repositories ✅  \n- **Fine-grained**: For specific repository access (advanced)\n\n#### **Security Best Practices:**\n```bash\n# 1. Never commit tokens to git\necho \".env\" \u003e\u003e .gitignore\necho \"*.token\" \u003e\u003e .gitignore\n\n# 2. Use environment variables in production\nexport HUGGINGFACE_TOKEN=\"hf_your_token\"\n\n# 3. Rotate tokens regularly\nhuggingface-cli auth token --new\n\n# 4. Check token validity\nhuggingface-cli auth whoami\n```\n\n#### **Troubleshooting Authentication:**\n```bash\n# Clear cached credentials\nhuggingface-cli auth clear\n\n# Re-login\nhuggingface-cli login\n\n# Test authentication\npython -c \"from huggingface_hub import HfApi; print(HfApi().whoami())\"\n```\n\n### 4. Advanced Space Configuration\n\n#### **Space Monitoring \u0026 Health Checks**\n```bash\n# Check space status and logs\nhuggingface-cli api info your_username/IDM-VTON --repo-type space\n\n# Monitor space runtime\npython -c \"\nfrom gradio_client import Client\nimport time\n\ntry:\n    client = Client('your_username/IDM-VTON')\n    print('✅ Space is running and accessible')\n    print(f'Space URL: {client.src}')\nexcept Exception as e:\n    print(f'❌ Space issue: {e}')\n\"\n\n# Check space build status\ncurl -H \"Authorization: Bearer $HUGGINGFACE_TOKEN\" \\\n     \"https://huggingface.co/api/spaces/your_username/IDM-VTON/runtime\"\n```\n\n#### **Space Configuration Management**\n```bash\n# Clone space repository for local editing\ngit clone https://huggingface.co/spaces/your_username/IDM-VTON\ncd IDM-VTON\n\n# Edit configuration files locally\n# - app.py (main application)\n# - requirements.txt (dependencies) \n# - README.md (space documentation)\n\n# Push changes\ngit add .\ngit commit -m \"Update space configuration\"\ngit push\n```\n\n#### **Environment Variables for Spaces**\n```bash\n# Set environment variables in your space\n# Go to: https://huggingface.co/spaces/your_username/IDM-VTON/settings\n\n# Common variables for IDM-VTON:\n# HF_TOKEN=your_token_here\n# GRADIO_SERVER_PORT=7860\n# GRADIO_ROOT_PATH=/\n```\n\n#### **Space Hardware \u0026 Performance**\n```bash\n# Check available hardware tiers\nhuggingface-cli api whoami\n\n# For HF Pro users - upgrade hardware:\n# Go to space settings → Hardware → Select GPU\n# Options: CPU basic (free) → T4 small → A10G → A100\n\n# Monitor space performance\npython -c \"\nimport time\nfrom gradio_client import Client\n\nclient = Client('your_username/IDM-VTON')\nstart_time = time.time()\n\n# Test inference speed\nresult = client.predict('test', api_name='/tryon')\nend_time = time.time()\n\nprint(f'Inference time: {end_time - start_time:.2f} seconds')\n\"\n```\n\n## Usage\n\n### Project Structure\n\n```\n├── examples/\n│   ├── person_images/          # Input person photos\n│   │   ├── Arnav_A.jpg        # Young male, front-facing\n│   │   ├── korean girl.png    # Female model, clean background\n│   │   ├── will_smith.jpg     # Male celebrity, professional\n│   │   └── Full Man.jpg       # 🆕 Full body male model\n│   ├── garment_images/        # Input garment photos\n│   │   ├── gucci upper.jpg    # Luxury brand upper garment\n│   │   ├── upper_2.jpg        # Alternative upper garment\n│   │   ├── upper_3.jpg        # 🆕 Red checkered shirt\n│   │   └── pants.jpg          # 🆕 Dark cargo pants\n│   └── results/               # Generated outputs (auto-created)\n├── inference.py               # Main script (supports both modes)\n├── two_step_pipeline.py       # Advanced two-step pipeline\n├── run_examples.py            # Interactive example runner\n├── layered_pipeline.py        # NEW: Sequential layered try-on\n├── .env.example              # Token template\n├── .gitignore                # Git ignore rules\n└── README.md                 # This documentation\n```\n\n### Basic Usage\n\n1. **Prepare your images:**\n   ```bash\n   # Add your person images to:\n   examples/person_images/your_person.jpg\n   \n   # Add your garment images to:\n   examples/garment_images/your_garment.jpg\n   ```\n\n2. **Update the script:**\n   - Open `inference.py`\n   - Update the file paths to your images:\n   ```python\n   \"background\": handle_file(\"./examples/person_images/your_person.jpg\"),\n   \"garm_img\": handle_file(\"./examples/garment_images/your_garment.jpg\"),\n   ```\n\n3. **Run the script:**\n   ```bash\n   conda activate viton\n   python inference.py\n   ```\n\n### Example Workflows\n\n#### **Example 1: Arnav + Gucci Upper**\n```python\nresult = client.predict(\n    dict={\n        \"background\": handle_file(\"./examples/person_images/Arnav_A.jpg\"),\n        \"layers\": [],\n        \"composite\": None\n    },\n    garm_img=handle_file(\"./examples/garment_images/gucci upper.jpg\"),\n    garment_des=\"Gucci upper garment\",\n    is_checked=True,\n    is_checked_crop=False,\n    denoise_steps=30,\n    seed=42,\n    api_name=\"/tryon\"\n)\n```\n\n#### **Example 2: Korean Girl + Alternative Upper**\n```python\nresult = client.predict(\n    dict={\n        \"background\": handle_file(\"./examples/person_images/korean girl.png\"),\n        \"layers\": [],\n        \"composite\": None\n    },\n    garm_img=handle_file(\"./examples/garment_images/upper_2.jpg\"),\n    garment_des=\"Stylish upper garment\",\n    is_checked=True,\n    is_checked_crop=False,\n    denoise_steps=30,\n    seed=42,\n    api_name=\"/tryon\"\n)\n```\n\n#### **Example 3: Will Smith + Gucci Upper**\n```python\nresult = client.predict(\n    dict={\n        \"background\": handle_file(\"./examples/person_images/will_smith.jpg\"),\n        \"layers\": [],\n        \"composite\": None\n    },\n    garm_img=handle_file(\"./examples/garment_images/gucci upper.jpg\"),\n    garment_des=\"Gucci upper on Will Smith\",\n    is_checked=True,\n    is_checked_crop=False,\n    denoise_steps=30,\n    seed=42,\n    api_name=\"/tryon\"\n)\n```\n\n### 🆕 New Example Combinations\n\nWith the new assets, you can now try:\n\n#### **Upper Body Combinations:**\n```bash\n# Example 5: Full Man + Red Checkered Shirt\npython two_step_pipeline.py  # Select option 5\n\n# Example 8: Korean Girl + Red Checkered Shirt  \npython two_step_pipeline.py  # Select option 8\n```\n\n#### **Lower Body Combinations (NEW!):**\n```bash\n# Example 6: Full Man + Dark Cargo Pants\npython two_step_pipeline.py  # Select option 6\n\n# Example 7: Arnav + Dark Cargo Pants\npython two_step_pipeline.py  # Select option 7\n```\n\n#### **Available Example Matrix:**\n| Person | Upper Garments | Lower Garments |\n|--------|---------------|----------------|\n| **Arnav_A** | ✅ Gucci, ✅ Upper_2, ✅ Upper_3 | ✅ Pants |\n| **Korean Girl** | ✅ Gucci, ✅ Upper_2, ✅ Upper_3 | ✅ Pants |\n| **Will Smith** | ✅ Gucci, ✅ Upper_2, ✅ Upper_3 | ✅ Pants |\n| **Full Man** | ✅ Gucci, ✅ Upper_2, ✅ Upper_3 | ✅ Pants |\n\n**Total Combinations**: 16 possible try-on combinations! 🎯\n\n### Available Examples\n\n#### **Person Images** (`examples/person_images/`)\n| Image | Description | Best For |\n|-------|-------------|----------|\n| `Arnav_A.jpg` | Young male, front-facing | Casual wear, formal shirts |\n| `korean girl.png` | Young female, clear background | Fashion items, dresses |\n| `will_smith.jpg` | Male celebrity, professional photo | Formal wear, jackets |\n\n#### **Garment Images** (`examples/garment_images/`)\n| Image | Description | Type |\n|-------|-------------|------|\n| `gucci upper.jpg` | Luxury brand upper garment | Premium shirt/top |\n| `upper_2.jpg` | Alternative upper garment | Casual/formal shirt |\n\n## Quick Start Guide\n\nFor experienced users, here's the fastest way to get started:\n\n```bash\n# 1. Setup environment\nconda create -n viton python=3.10 -y\nconda activate viton\npip install gradio_client huggingface_hub python-dotenv\n\n# 2. Login to HF\nhuggingface-cli login\n# Enter your token when prompted\n\n# 3. Duplicate space (replace 'your_username' with your HF username)\nhuggingface-cli repo duplicate yisol/IDM-VTON your_username/IDM-VTON --type space --private\n\n# 4. Wait for space to build (check status)\nhuggingface-cli api info your_username/IDM-VTON --repo-type space\n\n# 5. Setup token file\necho \"HUGGINGFACE_TOKEN=$(huggingface-cli auth token)\" \u003e .env\n\n# 6. Update inference.py with your space name and run\npython inference.py\n```\n\n**⚠️ Important**: Replace `your_username` with your actual Hugging Face username!\n\n## Parameters\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `background` | Person image to try clothes on | Required |\n| `garm_img` | Garment image to be worn | Required |\n| `garment_des` | Text description of garment | Required |\n| `is_checked` | Enable garment processing | `True` |\n| `is_checked_crop` | Enable automatic cropping | `False` |\n| `denoise_steps` | Number of denoising steps | `30` |\n| `seed` | Random seed for reproducibility | `42` |\n\n## Tips for Best Results\n\n### Person Images\n- Use high-resolution images (512x512 or higher)\n- Ensure the person is clearly visible and well-lit\n- Front-facing pose works best\n- Minimal background clutter\n\n### Garment Images\n- Use clean, isolated garment images\n- Good lighting and contrast\n- Flat lay or on mannequin works well\n- Clear view of the garment details\n\n## Troubleshooting\n\n### Common Issues\n\n1. **401 Unauthorized Error**\n   - Check your Hugging Face token\n   - Ensure the token has read access\n   - Verify your space name is correct\n\n2. **IndexError**\n   - Check image file paths are correct\n   - Ensure images are accessible\n   - Verify image formats (JPG, PNG supported)\n\n3. **Environment Issues**\n   - Activate the conda environment: `conda activate viton`\n   - Reinstall packages if needed: `pip install --upgrade gradio_client`\n\n### Debug Mode\n\nAdd this to your script for more detailed output:\n```python\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n```\n\n## Sample Results\n\nThe script generates two outputs:\n- **Main result**: Virtual try-on image showing the person wearing the garment\n- **Mask result**: Processing mask used by the model\n\n## Performance\n\n- **Processing time**: ~30-60 seconds per image (depends on HF Pro queue)\n- **Quality**: High-resolution diffusion-based results\n- **Rate limits**: None (with HF Pro space)\n\n### 📊 Performance Stats\n\n| Metric | Value | Note |\n|--------|-------|------|\n| **Processing Time** | ~30-60 seconds | Using HF Pro priority queue |\n| **Image Quality** | High-resolution | Diffusion-based generation |\n| **Success Rate** | 95%+ | With properly formatted inputs |\n| **Supported Formats** | JPG, PNG | Most common image formats |\n| **Max Resolution** | 1024x1024 | Optimal for detailed results |\n\n## License\n\nThis project uses the IDM-VTON model. Please check the original model's license and terms of use.\n\n## Credits\n\n- **IDM-VTON Model**: [yisol/IDM-VTON](https://huggingface.co/spaces/yisol/IDM-VTON)\n- **Gradio Client**: For API integration\n- **Hugging Face**: For hosting and infrastructure\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!\n\n## Support\n\nFor issues with:\n- **This script**: Create an issue in this repository\n- **IDM-VTON model**: Check the original space documentation\n- **Hugging Face**: Contact HF support\n\n---\n\n**Happy Virtual Try-On! 👕✨**\n\n### Interactive Example Runner\n\nFor easy testing of all combinations, use the interactive example runner:\n\n```bash\n# Run the interactive example menu\npython run_examples.py\n\n# Available options:\n# 1. Arnav + Gucci upper\n# 2. Korean girl + Gucci upper  \n# 3. Will Smith + Gucci upper\n# 4. Arnav + Alternative upper\n# 5. Korean girl + Alternative upper\n# all - Run all examples\n# q - Quit\n```\n\nThe runner will:\n- ✅ Automatically check for required files\n- ⏱️ Show processing time for each example\n- 📁 Save results with meaningful names\n- 🎯 Run individual or all examples with one command\n\n## 🔄 Two-Step Pipeline Approach\n\nThis project now supports an advanced **two-step pipeline** for superior results:\n\n### Step 1: Initial Processing\n- **Model**: `blackmamba2408/virtual-try-on`\n- **Purpose**: Initial garment fitting and pose alignment\n- **API**: `/virtual_tryon`\n- **Speed**: Fast initial processing\n- **Output**: Base virtual try-on result\n\n### Step 2: Refinement\n- **Model**: `blackmamba2408/IDM-VTON` \n- **Purpose**: High-quality refinement and detail enhancement\n- **API**: `/tryon`\n- **Features**: Advanced diffusion-based improvements\n- **Output**: Professional-grade final result\n\n### Pipeline Benefits\n✅ **Better Quality**: Two-stage processing for superior results  \n✅ **Flexibility**: Choose single-step or two-step approach  \n✅ **Optimized**: Each model handles what it does best  \n✅ **Robust**: Fallback options if one step fails  \n\n### Usage Options\n\n**Option 1: Two-Step Pipeline (Recommended)**\n```bash\npython two_step_pipeline.py\n# Interactive menu with all examples\n```\n\n**Option 2: Configure in inference.py**\n```python\nUSE_TWO_STEP = True  # Enable two-step pipeline\nUSE_TWO_STEP = False # Direct IDM-VTON only\n```\n\n**Option 3: Direct IDM-VTON**\n```bash\npython inference.py  # Uses current configuration\n```\n\n### 🔀 All Available Approaches\n\n| Approach | Speed | Quality | Use Case | Command |\n|----------|--------|---------|----------|---------|\n| **🆕 Layered Pipeline** | Slower | ⭐⭐⭐⭐⭐ | Complete outfits | `python layered_pipeline.py` |\n| **Two-Step Pipeline** | Medium | ⭐⭐⭐⭐⭐ | Single garment refinement | `python two_step_pipeline.py` |\n| **Direct IDM-VTON** | Fast | ⭐⭐⭐⭐ | Quick single garment | `python inference.py` |\n| **Virtual-Try-On Only** | Fastest | ⭐⭐⭐ | Preview/testing | Direct API call |\n\n### 🎯 Which Should You Use?\n\n- **👔 Complete Outfits**: Use `layered_pipeline.py` - applies pants first, then upper garment\n- **👕 Single Garment**: Use `two_step_pipeline.py` - refines single garment quality  \n- **⚡ Quick Tests**: Use `inference.py` - fast single garment application\n\n**🏆 Best Quality**: Layered Pipeline for complete outfits!\n**⚡ Best Speed**: Direct inference for single garments!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnavballincode%2Fidm_vton_api_implementation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnavballincode%2Fidm_vton_api_implementation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnavballincode%2Fidm_vton_api_implementation/lists"}