File size: 4,961 Bytes
d1283c1
d85819f
c6fef63
d85819f
 
d1283c1
4046b0f
33d171f
d1283c1
 
d85819f
 
d1283c1
 
d85819f
 
4046b0f
d85819f
 
 
377cfa0
 
 
d85819f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377cfa0
 
 
 
 
 
 
 
 
 
d85819f
 
 
 
 
 
 
 
 
 
4046b0f
 
 
 
 
55db221
 
d85819f
 
 
55db221
 
 
 
 
 
 
 
 
 
 
 
4046b0f
d85819f
4046b0f
 
 
d85819f
 
4046b0f
 
 
 
 
 
 
 
 
 
 
 
 
 
d85819f
 
4046b0f
d85819f
4046b0f
 
 
 
 
 
 
 
 
d85819f
 
4046b0f
d85819f
 
4046b0f
 
 
d85819f
 
377cfa0
55db221
377cfa0
 
 
 
 
 
 
 
 
 
 
 
 
d85819f
 
 
 
 
 
377cfa0
 
 
 
4046b0f
377cfa0
4046b0f
 
d85819f
377cfa0
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
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).