2026-01-04 20:00:16 +08:00
# Image-To-Video
2026-06-23 14:42:05 +08:00
This example demonstrates how to generate videos from images (image-to-video)
using Wan2.2, LTX2, HunyuanVideo-1.5, and Cosmos3 with vLLM-Omni's offline
inference API.
2026-01-04 20:00:16 +08:00
## Local CLI Usage
2026-02-07 21:14:53 +08:00
Download the example image:
```bash
wget https://vllm-public-assets.s3.us-west-2.amazonaws.com/vision_model_images/cherry_blossom.jpg
```
2026-01-04 20:00:16 +08:00
### Wan2.2-I2V-A14B-Diffusers (MoE)
2026-02-07 21:14:53 +08:00
2026-01-04 20:00:16 +08:00
```bash
python image_to_video.py \
--model Wan-AI/Wan2.2-I2V-A14B-Diffusers \
2026-02-07 21:14:53 +08:00
--image cherry_blossom.jpg \
--prompt "Cherry blossoms swaying gently in the breeze, petals falling, smooth motion" \
2026-02-11 17:17:48 +08:00
--negative-prompt "<optional quality filter>" \
2026-01-04 20:00:16 +08:00
--height 480 \
--width 832 \
2026-02-11 17:17:48 +08:00
--num-frames 48 \
--guidance-scale 5.0 \
--guidance-scale-high 6.0 \
--num-inference-steps 40 \
--boundary-ratio 0.875 \
--flow-shift 12.0 \
2026-01-04 20:00:16 +08:00
--fps 16 \
--output i2v_output.mp4
```
### Wan2.2-TI2V-5B-Diffusers (Unified)
2026-02-07 21:14:53 +08:00
2026-01-04 20:00:16 +08:00
```bash
python image_to_video.py \
--model Wan-AI/Wan2.2-TI2V-5B-Diffusers \
2026-02-07 21:14:53 +08:00
--image cherry_blossom.jpg \
--prompt "Cherry blossoms swaying gently in the breeze, petals falling, smooth motion" \
2026-02-11 17:17:48 +08:00
--negative-prompt "<optional quality filter>" \
2026-01-04 20:00:16 +08:00
--height 480 \
--width 832 \
2026-02-11 17:17:48 +08:00
--num-frames 48 \
--guidance-scale 4.0 \
--num-inference-steps 40 \
--flow-shift 12.0 \
2026-01-04 20:00:16 +08:00
--fps 16 \
--output i2v_output.mp4
```
2026-06-23 14:42:05 +08:00
### Cosmos3
```bash
# Cosmos3 bundles example frames under assets/ (any RGB image works too):
python image_to_video.py \
--model nvidia/Cosmos3-Nano \
--image /path/to/Cosmos3-Nano/assets/example_i2v_input.jpg \
--prompt "The scene comes to life with smooth, natural motion." \
--negative-prompt "blurry, distorted, low quality" \
--height 720 --width 1280 --num-frames 189 --fps 24 \
--num-inference-steps 35 --guidance-scale 6.0 \
--extra-body '{"flow_shift": 10.0, "max_sequence_length": 4096, "guardrails": false}' \
--output cosmos3_i2v.mp4
```
2026-01-04 20:00:16 +08:00
Key arguments:
- `--model` : Model ID (I2V-A14B for MoE, TI2V-5B for unified T2V+I2V).
- `--image` : Path to input image (required).
2026-06-23 14:42:05 +08:00
- `--extra-body` : JSON object of model-specific generation params, filtered against the model's declared `extra_body_params` (see [`vllm_omni/model_extras` ](../../../vllm_omni/model_extras )). Used by Cosmos3.
2026-01-04 20:00:16 +08:00
- `--prompt` : Text description of desired motion/animation.
- `--height/--width` : Output resolution (auto-calculated from image if not set). Dimensions should be multiples of 16.
2026-06-23 14:42:05 +08:00
- `--num-frames` : Number of frames (default: model-specific — Wan 81, LTX2 121, Cosmos3 189).
2026-02-11 17:17:48 +08:00
- `--guidance-scale` and `--guidance-scale-high` : CFG scale (applied to low/high-noise stages for MoE).
- `--negative-prompt` : Optional list of artifacts to suppress.
- `--boundary-ratio` : Boundary split ratio for two-stage MoE models.
2026-06-23 14:42:05 +08:00
- `--flow-shift` : Scheduler flow shift (default: model-specific — Wan/LTX2 5.0, Cosmos3 10.0).
2026-04-13 14:20:04 +08:00
- `--sample-solver` : Wan2.2 sampling solver. Use `unipc` for the default multistep solver, or `euler` for Lightning/Distill checkpoints.
2026-06-23 14:42:05 +08:00
- `--num-inference-steps` : Number of denoising steps (default: model-specific — Wan 50, LTX2 40, Cosmos3 35).
2026-01-04 20:00:16 +08:00
- `--fps` : Frames per second for the saved MP4 (requires `diffusers` export_to_video).
- `--output` : Path to save the generated video.
2026-02-11 17:17:48 +08:00
- `--vae-use-slicing` : Enable VAE slicing for memory optimization.
- `--vae-use-tiling` : Enable VAE tiling for memory optimization.
2026-04-13 14:20:04 +08:00
- `--cfg-parallel-size` : set it to 2 to enable CFG Parallel. See more examples in [`user_guide` ](https://github.com/vllm-project/vllm-omni/tree/main/docs/user_guide/diffusion/parallelism/cfg_parallel.md ).
2026-03-05 23:31:48 +08:00
- `--tensor-parallel-size` : tensor parallel size (effective for models that support TP, e.g. LTX2).
2026-01-23 22:43:00 +08:00
- `--enable-cpu-offload` : enable CPU offloading for diffusion models.
2026-02-26 21:31:10 +08:00
- `--use-hsdp` : Enable Hybrid Sharded Data Parallel to shard model weights across GPUs.
- `--hsdp-shard-size` : Number of GPUs to shard model weights across within each replica group. -1 (default) auto-calculates as world_size / replicate_size.
- `--hsdp-replicate-size` : Number of replica groups for HSDP. Each replica holds a full sharded copy. Default 1 means pure sharding (no replication).
2026-01-28 22:12:52 +08:00
2026-02-11 17:17:48 +08:00
> ℹ ️ If you encounter OOM errors, try using `--vae-use-slicing` and `--vae-use-tiling` to reduce memory usage.
2026-04-13 14:20:04 +08:00
For Wan2.2 LightX2V-converted local Diffusers directories and related LoRA
assets, see the [LoRA guide ](../../../docs/user_guide/diffusion/lora.md#wan22-lightx2v-offline-assembly ).