2025-12-12 15:14:52 +08:00
# Image-To-Image
2025-12-11 20:06:17 +08:00
This example edits an input image with `Qwen/Qwen-Image-Edit` using the `image_edit.py` CLI.
## Local CLI Usage
2025-12-18 18:16:32 +08:00
### Single Image Editing
2025-12-23 23:26:16 +08:00
Download the example image:
```bash
wget https://vllm-public-assets.s3.us-west-2.amazonaws.com/omni-assets/qwen-bear.png
```
Then run:
2025-12-11 20:06:17 +08:00
```bash
python image_edit.py \
2025-12-31 22:02:04 +08:00
--image qwen-bear.png \
2025-12-11 20:06:17 +08:00
--prompt "Let this mascot dance under the moon, surrounded by floating stars and poetic bubbles such as 'Be Kind'" \
--output output_image_edit.png \
--num_inference_steps 50 \
2025-12-31 22:02:04 +08:00
--cfg_scale 4.0
2025-12-18 18:16:32 +08:00
```
2025-12-19 16:50:32 +08:00
### Multiple Image Editing (Qwen-Image-Edit-2509)
2025-12-18 18:16:32 +08:00
2025-12-23 23:26:16 +08:00
For multiple image inputs, use `Qwen/Qwen-Image-Edit-2509` or `Qwen/Qwen-Image-Edit-2511` :
2025-12-18 18:16:32 +08:00
```bash
python image_edit.py \
--model Qwen/Qwen-Image-Edit-2509 \
--image img1.png img2.png \
--prompt "Combine these images into a single scene" \
--output output_image_edit.png \
--num_inference_steps 50 \
--cfg_scale 4.0 \
--guidance_scale 1.0
2025-12-11 20:06:17 +08:00
```
Key arguments:
2025-12-12 15:14:52 +08:00
2025-12-18 18:16:32 +08:00
- `--model` : model name or path. Use `Qwen/Qwen-Image-Edit-2509` or later for multiple image support.
- `--image` : path(s) to the source image(s) (PNG/JPG, converted to RGB). Can specify multiple images.
2025-12-11 20:06:17 +08:00
- `--prompt` / `--negative_prompt` : text description (string).
2025-12-18 18:16:32 +08:00
- `--cfg_scale` : true classifier-free guidance scale (default: 4.0). Classifier-free guidance is enabled by setting cfg_scale > 1 and providing a negative_prompt. Higher guidance scale encourages images closely linked to the text prompt, usually at the expense of lower image quality.
- `--guidance_scale` : guidance scale for guidance-distilled models (default: 1.0, disabled). Unlike classifier-free guidance (--cfg_scale), guidance-distilled models take the guidance scale directly as an input parameter. Enabled when guidance_scale > 1. Ignored when not using guidance-distilled models.
2025-12-11 20:06:17 +08:00
- `--num_inference_steps` : diffusion sampling steps (more steps = higher quality, slower).
- `--output` : path to save the generated PNG.
2026-01-28 22:12:52 +08:00
- `--vae_use_slicing` : enable VAE slicing for memory optimization.
- `--vae_use_tiling` : enable VAE tiling for memory optimization.
2026-01-23 22:43:00 +08:00
- `--enable-cpu-offload` : enable CPU offloading for diffusion models.
2026-01-28 22:12:52 +08:00
> ℹ ️ If you encounter OOM errors, try using `--vae_use_slicing` and `--vae_use_tiling` to reduce memory usage.