2025-11-30 18:20:44 +08:00
|
|
|
# Qwen-Image Offline Inference
|
2025-11-30 17:46:39 +08:00
|
|
|
|
2025-12-11 20:06:17 +08:00
|
|
|
Source <https://github.com/vllm-project/vllm-omni/tree/main/examples/offline_inference/text_to_image>.
|
2025-11-30 17:46:39 +08:00
|
|
|
|
|
|
|
|
|
2025-12-11 20:06:17 +08:00
|
|
|
This folder provides two simple entrypoints for experimenting with `Qwen/Qwen-Image` `Tongyi-MAI/Z-Image-Turbo` using vLLM-Omni:
|
2025-11-30 17:46:39 +08:00
|
|
|
|
|
|
|
|
- `text_to_image.py`: command-line script for single image generation.
|
2025-11-30 18:20:44 +08:00
|
|
|
- `web_demo.py`: lightweight Gradio UI for interactive prompt/seed/CFG exploration.
|
2025-11-30 17:46:39 +08:00
|
|
|
|
2025-11-30 18:20:44 +08:00
|
|
|
|
|
|
|
|
## Local CLI Usage
|
2025-11-30 17:46:39 +08:00
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python text_to_image.py \
|
2025-12-11 20:06:17 +08:00
|
|
|
--model Tongyi-MAI/Z-Image-Turbo \
|
2025-11-30 17:46:39 +08:00
|
|
|
--prompt "a cup of coffee on the table" \
|
|
|
|
|
--seed 42 \
|
|
|
|
|
--cfg_scale 4.0 \
|
|
|
|
|
--num_images_per_prompt 1 \
|
|
|
|
|
--num_inference_steps 50 \
|
|
|
|
|
--height 1024 \
|
|
|
|
|
--width 1024 \
|
|
|
|
|
--output outputs/coffee.png
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Key arguments:
|
|
|
|
|
|
|
|
|
|
- `--prompt`: text description (string).
|
|
|
|
|
- `--seed`: integer seed for deterministic sampling.
|
|
|
|
|
- `--cfg_scale`: true CFG scale (model-specific guidance strength).
|
|
|
|
|
- `--num_images_per_prompt`: number of images to generate per prompt (saves as `output`, `output_1`, ...).
|
|
|
|
|
- `--num_inference_steps`: diffusion sampling steps (more steps = higher quality, slower).
|
|
|
|
|
- `--height/--width`: output resolution (defaults 1024x1024).
|
|
|
|
|
- `--output`: path to save the generated PNG.
|
|
|
|
|
|
2025-11-30 18:20:44 +08:00
|
|
|
## Web UI Demo
|
2025-11-30 17:46:39 +08:00
|
|
|
|
|
|
|
|
Launch the gradio demo:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python gradio_demo.py --port 7862
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then open `http://localhost:7862/` on your local browser to interact with the web UI.
|
|
|
|
|
|
2025-11-30 18:20:44 +08:00
|
|
|
## Example materials
|
|
|
|
|
|
2025-11-30 17:46:39 +08:00
|
|
|
??? abstract "gradio_demo.py"
|
|
|
|
|
``````py
|
2025-12-11 20:06:17 +08:00
|
|
|
--8<-- "examples/offline_inference/text_to_image/gradio_demo.py"
|
2025-11-30 18:20:44 +08:00
|
|
|
``````
|
|
|
|
|
??? abstract "text_to_image.py"
|
|
|
|
|
``````py
|
2025-12-11 20:06:17 +08:00
|
|
|
--8<-- "examples/offline_inference/text_to_image/text_to_image.py"
|
2025-11-30 17:46:39 +08:00
|
|
|
``````
|