Spaces:
Sleeping
Sleeping
| title: Virtual Try-On ZeroGPU Demo | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: gradio | |
| sdk_version: 5.7.1 | |
| python_version: "3.10" | |
| app_file: app.py | |
| pinned: false | |
| license: other | |
| short_description: ZeroGPU xlarge Gradio demo for image-based virtual try-on. | |
| # Virtual Try-On ZeroGPU Demo | |
| This Space is a Gradio SDK deployment wrapper for the JoyAI/XVideo virtual try-on inference path. | |
| ## Inputs | |
| - One multimodal input box for image files and text | |
| - Upload order: first image is the person image; remaining images are garment reference images | |
| - Default prompt buttons: no reference, one reference, two references, and multiple references | |
| ## Output | |
| - One generated try-on image | |
| ## ZeroGPU | |
| The inference callback is decorated with: | |
| ```python | |
| @spaces.GPU(size="xlarge", duration=180) | |
| ``` | |
| Use ZeroGPU `xlarge` because the model is expected to need at least 60 GB of VRAM. | |
| ## Required Space Variables | |
| Set these in the Space settings: | |
| ```text | |
| MODEL_ID=your-org/your-vton-model | |
| ``` | |
| If model files are stored in a Hugging Face Storage Bucket, mount the bucket into | |
| the Space and set: | |
| ```text | |
| MODEL_LOCAL_DIR=/models | |
| ``` | |
| In this mode `MODEL_ID` is not required. The app loads files directly from the | |
| mounted bucket path. | |
| If the model repository is private, add this as a Space Secret: | |
| ```text | |
| HF_TOKEN=hf_xxxxxxxxxxxxxxxxx | |
| ``` | |
| Optional variables: | |
| ```text | |
| MODEL_REVISION=main | |
| JOY_CONFIG_PATH=configs/editing_exp/edit_1024p_demo.py | |
| JOY_TRANSFORMER_PATH=transformer | |
| JOY_DIT_CKPT_TYPE=safetensor | |
| JOY_MODEL_PATH=FireRed-Image-Edit-1.0 | |
| JOY_VAE_PATH=FireRed-Image-Edit-1.0/vae/diffusion_pytorch_model.safetensors | |
| QWEN235_CHAT_URL=http://ai-api.jdcloud.com/v1/chat/completions | |
| QWEN235_MODEL=qwen3-vl-235 | |
| HF_HOME=/data/.huggingface | |
| ``` | |
| For Prompt Enhancer, add one of these as a Space Secret: | |
| ```text | |
| QWEN235_API_KEY=your_api_key | |
| ``` | |
| or: | |
| ```text | |
| OPENAI_API_KEY=your_api_key | |
| ``` | |
| ## Expected Model Repository Layout | |
| This wrapper downloads `MODEL_ID` with `huggingface_hub.snapshot_download`. | |
| The model repo should contain the JoyAI/XVideo code or a `code/` or `JoyAI-Image/` folder with the `xvideo` package. | |
| It also needs the config and checkpoints referenced by the variables above. | |
| ```text | |
| MODEL_ID repo | |
| βββ code/ | |
| β βββ xvideo/ | |
| βββ configs/ | |
| β βββ editing_exp/ | |
| β βββ edit_1024p_demo.py | |
| βββ transformer/ | |
| β βββ model-00001-of-00005.safetensors | |
| β βββ ... | |
| βββ FireRed-Image-Edit-1.0/ | |
| βββ processor/ | |
| βββ text_encoder/ | |
| βββ tokenizer/ | |
| βββ vae/ | |
| ``` | |
| If the config/checkpoint files live at different paths, set: | |
| ```text | |
| JOY_CONFIG_PATH=relative/or/absolute/config.py | |
| JOY_TRANSFORMER_PATH=relative/or/absolute/transformer_or_step_xxx.pth | |
| JOY_DIT_CKPT_TYPE=safetensor | |
| JOY_MODEL_PATH=relative/or/absolute/FireRed-Image-Edit-1.0 | |
| JOY_VAE_PATH=relative/or/absolute/FireRed-Image-Edit-1.0/vae/diffusion_pytorch_model.safetensors | |
| JOY_TEXT_ENCODER_PATH=relative/or/absolute/FireRed-Image-Edit-1.0/text_encoder | |
| JOY_PROCESSOR_PATH=relative/or/absolute/FireRed-Image-Edit-1.0/processor | |
| JOY_TOKENIZER_PATH=relative/or/absolute/FireRed-Image-Edit-1.0/tokenizer | |
| ``` | |
| The inference logic follows `tryon_infer.py`: | |
| ```text | |
| processed images = [garment_image, person_image] | |
| prompt = <image><image> + try-on instruction | |
| output = one generated PIL image | |
| ``` | |
| Prompt Enhancer is enabled by default in the UI. It sends the primary garment image and person image to the configured Qwen3-VL-235 endpoint, then displays the enhanced prompt used for generation. | |
| If multiple garment images are uploaded, the app currently uses the first garment reference image as the primary garment. It does not pretend to perform multi-reference fusion. | |
| The landing UI includes local visual assets under `assets/`: | |
| ```text | |
| assets/ | |
| βββ tryon_logo_compact.png | |
| βββ showcase/ | |
| βββ case_0.jpg | |
| βββ case_1.jpg | |
| βββ case_2.jpg | |
| βββ case_3.jpg | |
| ``` | |
| ## Deployment Steps | |
| 1. Create a new Hugging Face Space with SDK `Gradio` and hardware `ZeroGPU`. | |
| 2. Copy these files into the Space repository. | |
| 3. Add any model-specific Python dependencies to `requirements.txt`. | |
| 4. Use one of these model storage options: | |
| - Model repo: set `MODEL_ID` as a Space Variable. | |
| - Storage Bucket: mount the bucket into the Space, for example at `/models`, | |
| then set `MODEL_LOCAL_DIR=/models`. | |
| 5. Set the JoyAI checkpoint/config variables listed above. | |
| 6. If the model storage is private, set `HF_TOKEN` as a Space Secret. | |
| 7. Push the Space repository. | |
| 8. Open the Space and run a test with one person image and one garment image. | |
| Do not commit large model weights to this Space repository. Keep weights in a | |
| Hugging Face Model Repo or a Hugging Face Storage Bucket. | |
| For the complete Storage Bucket deployment flow, including the | |
| `Davidscut/Tryon-demo-storage` mount setup and path variables, see | |
| [`DEPLOYMENT_BUCKET.md`](DEPLOYMENT_BUCKET.md). | |