Tryon-demo / README.md
Davidscut's picture
Update README.md
33d171f verified
|
Raw
History Blame Contribute Delete
4.96 kB
---
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).