a-r-r-o-w HF Staff commited on
Commit
0980267
·
verified ·
1 Parent(s): 567882c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +742 -3
README.md CHANGED
@@ -1,3 +1,742 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ - zh
6
+ tags:
7
+ - video generation
8
+ - video-to-video editing
9
+ - refernce-to-video
10
+
11
+ pipeline_tag: image-to-video
12
+ ---
13
+ # Wan2.1
14
+
15
+ <p align="center">
16
+ <img src="assets/logo.png" width="400"/>
17
+ <p>
18
+
19
+ <p align="center">
20
+ 💜 <a href="https://wan.video"><b>Wan</b></a> &nbsp&nbsp | &nbsp&nbsp 🖥️ <a href="https://github.com/Wan-Video/Wan2.1">GitHub</a> &nbsp&nbsp | &nbsp&nbsp🤗 <a href="https://huggingface.co/Wan-AI/">Hugging Face</a>&nbsp&nbsp | &nbsp&nbsp🤖 <a href="https://modelscope.cn/organization/Wan-AI">ModelScope</a>&nbsp&nbsp | &nbsp&nbsp 📑 <a href="https://arxiv.org/abs/2503.20314">Technical Report</a> &nbsp&nbsp | &nbsp&nbsp 📑 <a href="https://wan.video/welcome?spm=a2ty_o02.30011076.0.0.6c9ee41eCcluqg">Blog</a> &nbsp&nbsp | &nbsp&nbsp💬 <a href="https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg">WeChat Group</a>&nbsp&nbsp | &nbsp&nbsp 📖 <a href="https://discord.gg/AKNgpMK4Yj">Discord</a>&nbsp&nbsp
21
+ <br>
22
+
23
+ -----
24
+
25
+ [**Wan: Open and Advanced Large-Scale Video Generative Models**](https://arxiv.org/abs/2503.20314) <be>
26
+
27
+ In this repository, we present **Wan2.1**, a comprehensive and open suite of video foundation models that pushes the boundaries of video generation. **Wan2.1** offers these key features:
28
+ - 👍 **SOTA Performance**: **Wan2.1** consistently outperforms existing open-source models and state-of-the-art commercial solutions across multiple benchmarks.
29
+ - 👍 **Supports Consumer-grade GPUs**: The T2V-1.3B model requires only 8.19 GB VRAM, making it compatible with almost all consumer-grade GPUs. It can generate a 5-second 480P video on an RTX 4090 in about 4 minutes (without optimization techniques like quantization). Its performance is even comparable to some closed-source models.
30
+ - 👍 **Multiple Tasks**: **Wan2.1** excels in Text-to-Video, Image-to-Video, Video Editing, Text-to-Image, and Video-to-Audio, advancing the field of video generation.
31
+ - 👍 **Visual Text Generation**: **Wan2.1** is the first video model capable of generating both Chinese and English text, featuring robust text generation that enhances its practical applications.
32
+ - 👍 **Powerful Video VAE**: **Wan-VAE** delivers exceptional efficiency and performance, encoding and decoding 1080P videos of any length while preserving temporal information, making it an ideal foundation for video and image generation.
33
+
34
+ ## Video Demos
35
+
36
+ <div align="center">
37
+ <video width="80%" controls>
38
+ <source src="https://cloud.video.taobao.com/vod/Jth64Y7wNoPcJki_Bo1ZJTDBvNjsgjlVKsNs05Fqfps.mp4" type="video/mp4">
39
+ Your browser does not support the video tag.
40
+ </video>
41
+ </div>
42
+
43
+ ## 🔥 Latest News!!
44
+
45
+ * May 14, 2025: 👋 We introduce **Wan2.1** [VACE](https://github.com/ali-vilab/VACE), an all-in-one model for video creation and editing, along with its [inference code](#run-vace), [weights](#model-download), and [technical report](https://arxiv.org/abs/2503.07598)!
46
+ * Apr 17, 2025: 👋 We introduce **Wan2.1** [FLF2V](#run-first-last-frame-to-video-generation) with its inference code and weights!
47
+ * Mar 21, 2025: 👋 We are excited to announce the release of the **Wan2.1** [technical report](https://files.alicdn.com/tpsservice/5c9de1c74de03972b7aa657e5a54756b.pdf). We welcome discussions and feedback!
48
+ * Mar 3, 2025: 👋 **Wan2.1**'s T2V and I2V have been integrated into Diffusers ([T2V](https://huggingface.co/docs/diffusers/main/en/api/pipelines/wan#diffusers.WanPipeline) | [I2V](https://huggingface.co/docs/diffusers/main/en/api/pipelines/wan#diffusers.WanImageToVideoPipeline)). Feel free to give it a try!
49
+ * Feb 27, 2025: 👋 **Wan2.1** has been integrated into [ComfyUI](https://comfyanonymous.github.io/ComfyUI_examples/wan/). Enjoy!
50
+ * Feb 25, 2025: 👋 We've released the inference code and weights of **Wan2.1**.
51
+
52
+ ## Community Works
53
+ If your work has improved **Wan2.1** and you would like more people to see it, please inform us.
54
+ - [Phantom](https://github.com/Phantom-video/Phantom) has developed a unified video generation framework for single and multi-subject references based on **Wan2.1-T2V-1.3B**. Please refer to [their examples](https://github.com/Phantom-video/Phantom).
55
+ - [UniAnimate-DiT](https://github.com/ali-vilab/UniAnimate-DiT), based on **Wan2.1-14B-I2V**, has trained a Human image animation model and has open-sourced the inference and training code. Feel free to enjoy it!
56
+ - [CFG-Zero](https://github.com/WeichenFan/CFG-Zero-star) enhances **Wan2.1** (covering both T2V and I2V models) from the perspective of CFG.
57
+ - [TeaCache](https://github.com/ali-vilab/TeaCache) now supports **Wan2.1** acceleration, capable of increasing speed by approximately 2x. Feel free to give it a try!
58
+ - [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio) provides more support for **Wan2.1**, including video-to-video, FP8 quantization, VRAM optimization, LoRA training, and more. Please refer to [their examples](https://github.com/modelscope/DiffSynth-Studio/tree/main/examples/wanvideo).
59
+
60
+
61
+ ## 📑 Todo List
62
+ - Wan2.1 Text-to-Video
63
+ - [x] Multi-GPU Inference code of the 14B and 1.3B models
64
+ - [x] Checkpoints of the 14B and 1.3B models
65
+ - [x] Gradio demo
66
+ - [x] ComfyUI integration
67
+ - [x] Diffusers integration
68
+ - [ ] Diffusers + Multi-GPU Inference
69
+ - Wan2.1 Image-to-Video
70
+ - [x] Multi-GPU Inference code of the 14B model
71
+ - [x] Checkpoints of the 14B model
72
+ - [x] Gradio demo
73
+ - [x] ComfyUI integration
74
+ - [x] Diffusers integration
75
+ - [ ] Diffusers + Multi-GPU Inference
76
+ - Wan2.1 First-Last-Frame-to-Video
77
+ - [x] Multi-GPU Inference code of the 14B model
78
+ - [x] Checkpoints of the 14B model
79
+ - [x] Gradio demo
80
+ - [ ] ComfyUI integration
81
+ - [x] Diffusers integration
82
+ - [ ] Diffusers + Multi-GPU Inference
83
+ - Wan2.1 VACE
84
+ - [x] Multi-GPU Inference code of the 14B and 1.3B models
85
+ - [x] Checkpoints of the 14B and 1.3B models
86
+ - [x] Gradio demo
87
+ - [x] ComfyUI integration
88
+ - [x] Diffusers integration
89
+ - [ ] Diffusers + Multi-GPU Inference
90
+
91
+ ## Quickstart
92
+
93
+ #### Installation
94
+ Clone the repo:
95
+ ```sh
96
+ git clone https://github.com/Wan-Video/Wan2.1.git
97
+ cd Wan2.1
98
+ ```
99
+
100
+ Install dependencies:
101
+ ```sh
102
+ # Ensure torch >= 2.4.0
103
+ pip install -r requirements.txt
104
+ ```
105
+
106
+
107
+ #### Model Download
108
+
109
+ | Models | Download Link | Notes |
110
+ |--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|
111
+ | T2V-14B | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-T2V-14B) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-T2V-14B) | Supports both 480P and 720P
112
+ | I2V-14B-720P | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-I2V-14B-720P) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-I2V-14B-720P) | Supports 720P
113
+ | I2V-14B-480P | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-I2V-14B-480P) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-I2V-14B-480P) | Supports 480P
114
+ | T2V-1.3B | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-T2V-1.3B) | Supports 480P
115
+ | FLF2V-14B | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-FLF2V-14B-720P) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-FLF2V-14B-720P) | Supports 720P
116
+ | VACE-1.3B | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-VACE-1.3B) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-VACE-1.3B) | Supports 480P
117
+ | VACE-14B | 🤗 [Huggingface](https://huggingface.co/Wan-AI/Wan2.1-VACE-14B) 🤖 [ModelScope](https://www.modelscope.cn/models/Wan-AI/Wan2.1-VACE-14B) | Supports both 480P and 720P
118
+
119
+ > 💡Note:
120
+ > * The 1.3B model is capable of generating videos at 720P resolution. However, due to limited training at this resolution, the results are generally less stable compared to 480P. For optimal performance, we recommend using 480P resolution.
121
+ > * For the first-last frame to video generation, we train our model primarily on Chinese text-video pairs. Therefore, we recommend using Chinese prompt to achieve better results.
122
+
123
+
124
+ Download models using huggingface-cli:
125
+ ``` sh
126
+ pip install "huggingface_hub[cli]"
127
+ huggingface-cli download Wan-AI/Wan2.1-T2V-14B --local-dir ./Wan2.1-T2V-14B
128
+ ```
129
+
130
+ Download models using modelscope-cli:
131
+ ``` sh
132
+ pip install modelscope
133
+ modelscope download Wan-AI/Wan2.1-T2V-14B --local_dir ./Wan2.1-T2V-14B
134
+ ```
135
+ #### Run Text-to-Video Generation
136
+
137
+ This repository supports two Text-to-Video models (1.3B and 14B) and two resolutions (480P and 720P). The parameters and configurations for these models are as follows:
138
+
139
+ <table>
140
+ <thead>
141
+ <tr>
142
+ <th rowspan="2">Task</th>
143
+ <th colspan="2">Resolution</th>
144
+ <th rowspan="2">Model</th>
145
+ </tr>
146
+ <tr>
147
+ <th>480P</th>
148
+ <th>720P</th>
149
+ </tr>
150
+ </thead>
151
+ <tbody>
152
+ <tr>
153
+ <td>t2v-14B</td>
154
+ <td style="color: green;">✔️</td>
155
+ <td style="color: green;">✔️</td>
156
+ <td>Wan2.1-T2V-14B</td>
157
+ </tr>
158
+ <tr>
159
+ <td>t2v-1.3B</td>
160
+ <td style="color: green;">✔️</td>
161
+ <td style="color: red;">❌</td>
162
+ <td>Wan2.1-T2V-1.3B</td>
163
+ </tr>
164
+ </tbody>
165
+ </table>
166
+
167
+
168
+ ##### (1) Without Prompt Extension
169
+
170
+ To facilitate implementation, we will start with a basic version of the inference process that skips the [prompt extension](#2-using-prompt-extention) step.
171
+
172
+ - Single-GPU inference
173
+
174
+ ``` sh
175
+ python generate.py --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
176
+ ```
177
+
178
+ If you encounter OOM (Out-of-Memory) issues, you can use the `--offload_model True` and `--t5_cpu` options to reduce GPU memory usage. For example, on an RTX 4090 GPU:
179
+
180
+ ``` sh
181
+ python generate.py --task t2v-1.3B --size 832*480 --ckpt_dir ./Wan2.1-T2V-1.3B --offload_model True --t5_cpu --sample_shift 8 --sample_guide_scale 6 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
182
+ ```
183
+
184
+ > 💡Note: If you are using the `T2V-1.3B` model, we recommend setting the parameter `--sample_guide_scale 6`. The `--sample_shift parameter` can be adjusted within the range of 8 to 12 based on the performance.
185
+
186
+
187
+ - Multi-GPU inference using FSDP + xDiT USP
188
+
189
+ We use FSDP and [xDiT](https://github.com/xdit-project/xDiT) USP to accelerate inference.
190
+
191
+ * Ulysess Strategy
192
+
193
+ If you want to use [`Ulysses`](https://arxiv.org/abs/2309.14509) strategy, you should set `--ulysses_size $GPU_NUMS`. Note that the `num_heads` should be divisible by `ulysses_size` if you wish to use `Ulysess` strategy. For the 1.3B model, the `num_heads` is `12` which can't be divided by 8 (as most multi-GPU machines have 8 GPUs). Therefore, it is recommended to use `Ring Strategy` instead.
194
+
195
+ * Ring Strategy
196
+
197
+ If you want to use [`Ring`](https://arxiv.org/pdf/2310.01889) strategy, you should set `--ring_size $GPU_NUMS`. Note that the `sequence length` should be divisible by `ring_size` when using the `Ring` strategy.
198
+
199
+ Of course, you can also combine the use of `Ulysses` and `Ring` strategies.
200
+
201
+
202
+ ``` sh
203
+ pip install "xfuser>=0.4.1"
204
+ torchrun --nproc_per_node=8 generate.py --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --dit_fsdp --t5_fsdp --ulysses_size 8 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
205
+ ```
206
+
207
+
208
+ ##### (2) Using Prompt Extension
209
+
210
+ Extending the prompts can effectively enrich the details in the generated videos, further enhancing the video quality. Therefore, we recommend enabling prompt extension. We provide the following two methods for prompt extension:
211
+
212
+ - Use the Dashscope API for extension.
213
+ - Apply for a `dashscope.api_key` in advance ([EN](https://www.alibabacloud.com/help/en/model-studio/getting-started/first-api-call-to-qwen) | [CN](https://help.aliyun.com/zh/model-studio/getting-started/first-api-call-to-qwen)).
214
+ - Configure the environment variable `DASH_API_KEY` to specify the Dashscope API key. For users of Alibaba Cloud's international site, you also need to set the environment variable `DASH_API_URL` to 'https://dashscope-intl.aliyuncs.com/api/v1'. For more detailed instructions, please refer to the [dashscope document](https://www.alibabacloud.com/help/en/model-studio/developer-reference/use-qwen-by-calling-api?spm=a2c63.p38356.0.i1).
215
+ - Use the `qwen-plus` model for text-to-video tasks and `qwen-vl-max` for image-to-video tasks.
216
+ - You can modify the model used for extension with the parameter `--prompt_extend_model`. For example:
217
+ ```sh
218
+ DASH_API_KEY=your_key python generate.py --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage" --use_prompt_extend --prompt_extend_method 'dashscope' --prompt_extend_target_lang 'zh'
219
+ ```
220
+
221
+ - Using a local model for extension.
222
+
223
+ - By default, the Qwen model on HuggingFace is used for this extension. Users can choose Qwen models or other models based on the available GPU memory size.
224
+ - For text-to-video tasks, you can use models like `Qwen/Qwen2.5-14B-Instruct`, `Qwen/Qwen2.5-7B-Instruct` and `Qwen/Qwen2.5-3B-Instruct`.
225
+ - For image-to-video or first-last-frame-to-video tasks, you can use models like `Qwen/Qwen2.5-VL-7B-Instruct` and `Qwen/Qwen2.5-VL-3B-Instruct`.
226
+ - Larger models generally provide better extension results but require more GPU memory.
227
+ - You can modify the model used for extension with the parameter `--prompt_extend_model` , allowing you to specify either a local model path or a Hugging Face model. For example:
228
+
229
+ ``` sh
230
+ python generate.py --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage" --use_prompt_extend --prompt_extend_method 'local_qwen' --prompt_extend_target_lang 'zh'
231
+ ```
232
+
233
+
234
+ ##### (3) Running with Diffusers
235
+
236
+ You can easily inference **Wan2.1**-T2V using Diffusers with the following command:
237
+ ``` python
238
+ import torch
239
+ from diffusers.utils import export_to_video
240
+ from diffusers import AutoencoderKLWan, WanPipeline
241
+ from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
242
+
243
+ # Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers
244
+ model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
245
+ vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
246
+ flow_shift = 5.0 # 5.0 for 720P, 3.0 for 480P
247
+ scheduler = UniPCMultistepScheduler(prediction_type='flow_prediction', use_flow_sigmas=True, num_train_timesteps=1000, flow_shift=flow_shift)
248
+ pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
249
+ pipe.scheduler = scheduler
250
+ pipe.to("cuda")
251
+
252
+ prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
253
+ negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"
254
+
255
+ output = pipe(
256
+ prompt=prompt,
257
+ negative_prompt=negative_prompt,
258
+ height=720,
259
+ width=1280,
260
+ num_frames=81,
261
+ guidance_scale=5.0,
262
+ ).frames[0]
263
+ export_to_video(output, "output.mp4", fps=16)
264
+ ```
265
+ > 💡Note: Please note that this example does not integrate Prompt Extension and distributed inference. We will soon update with the integrated prompt extension and multi-GPU version of Diffusers.
266
+
267
+
268
+ ##### (4) Running local gradio
269
+
270
+ ``` sh
271
+ cd gradio
272
+ # if one uses dashscope’s API for prompt extension
273
+ DASH_API_KEY=your_key python t2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir ./Wan2.1-T2V-14B
274
+
275
+ # if one uses a local model for prompt extension
276
+ python t2v_14B_singleGPU.py --prompt_extend_method 'local_qwen' --ckpt_dir ./Wan2.1-T2V-14B
277
+ ```
278
+
279
+
280
+
281
+ #### Run Image-to-Video Generation
282
+
283
+ Similar to Text-to-Video, Image-to-Video is also divided into processes with and without the prompt extension step. The specific parameters and their corresponding settings are as follows:
284
+ <table>
285
+ <thead>
286
+ <tr>
287
+ <th rowspan="2">Task</th>
288
+ <th colspan="2">Resolution</th>
289
+ <th rowspan="2">Model</th>
290
+ </tr>
291
+ <tr>
292
+ <th>480P</th>
293
+ <th>720P</th>
294
+ </tr>
295
+ </thead>
296
+ <tbody>
297
+ <tr>
298
+ <td>i2v-14B</td>
299
+ <td style="color: green;">❌</td>
300
+ <td style="color: green;">✔️</td>
301
+ <td>Wan2.1-I2V-14B-720P</td>
302
+ </tr>
303
+ <tr>
304
+ <td>i2v-14B</td>
305
+ <td style="color: green;">✔️</td>
306
+ <td style="color: red;">❌</td>
307
+ <td>Wan2.1-T2V-14B-480P</td>
308
+ </tr>
309
+ </tbody>
310
+ </table>
311
+
312
+
313
+ ##### (1) Without Prompt Extension
314
+
315
+ - Single-GPU inference
316
+ ```sh
317
+ python generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
318
+ ```
319
+
320
+ > 💡For the Image-to-Video task, the `size` parameter represents the area of the generated video, with the aspect ratio following that of the original input image.
321
+
322
+
323
+ - Multi-GPU inference using FSDP + xDiT USP
324
+
325
+ ```sh
326
+ pip install "xfuser>=0.4.1"
327
+ torchrun --nproc_per_node=8 generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --dit_fsdp --t5_fsdp --ulysses_size 8 --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
328
+ ```
329
+
330
+ ##### (2) Using Prompt Extension
331
+
332
+
333
+ The process of prompt extension can be referenced [here](#2-using-prompt-extention).
334
+
335
+ Run with local prompt extension using `Qwen/Qwen2.5-VL-7B-Instruct`:
336
+ ```
337
+ python generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --use_prompt_extend --prompt_extend_model Qwen/Qwen2.5-VL-7B-Instruct --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
338
+ ```
339
+
340
+ Run with remote prompt extension using `dashscope`:
341
+ ```
342
+ DASH_API_KEY=your_key python generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --use_prompt_extend --prompt_extend_method 'dashscope' --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
343
+ ```
344
+
345
+
346
+ ##### (3) Running with Diffusers
347
+
348
+ You can easily inference **Wan2.1**-I2V using Diffusers with the following command:
349
+ ``` python
350
+ import torch
351
+ import numpy as np
352
+ from diffusers import AutoencoderKLWan, WanImageToVideoPipeline
353
+ from diffusers.utils import export_to_video, load_image
354
+ from transformers import CLIPVisionModel
355
+
356
+ # Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers
357
+ model_id = "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers"
358
+ image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32)
359
+ vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
360
+ pipe = WanImageToVideoPipeline.from_pretrained(model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16)
361
+ pipe.to("cuda")
362
+
363
+ image = load_image(
364
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
365
+ )
366
+ max_area = 720 * 1280
367
+ aspect_ratio = image.height / image.width
368
+ mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
369
+ height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
370
+ width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
371
+ image = image.resize((width, height))
372
+ prompt = (
373
+ "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in "
374
+ "the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot."
375
+ )
376
+ negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"
377
+
378
+ output = pipe(
379
+ image=image,
380
+ prompt=prompt,
381
+ negative_prompt=negative_prompt,
382
+ height=height, width=width,
383
+ num_frames=81,
384
+ guidance_scale=5.0
385
+ ).frames[0]
386
+ export_to_video(output, "output.mp4", fps=16)
387
+
388
+ ```
389
+ > 💡Note: Please note that this example does not integrate Prompt Extension and distributed inference. We will soon update with the integrated prompt extension and multi-GPU version of Diffusers.
390
+
391
+
392
+ ##### (4) Running local gradio
393
+
394
+ ```sh
395
+ cd gradio
396
+ # if one only uses 480P model in gradio
397
+ DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P
398
+
399
+ # if one only uses 720P model in gradio
400
+ DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
401
+
402
+ # if one uses both 480P and 720P models in gradio
403
+ DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
404
+ ```
405
+
406
+
407
+ #### Run First-Last-Frame-to-Video Generation
408
+
409
+ First-Last-Frame-to-Video is also divided into processes with and without the prompt extension step. Currently, only 720P is supported. The specific parameters and corresponding settings are as follows:
410
+ <table>
411
+ <thead>
412
+ <tr>
413
+ <th rowspan="2">Task</th>
414
+ <th colspan="2">Resolution</th>
415
+ <th rowspan="2">Model</th>
416
+ </tr>
417
+ <tr>
418
+ <th>480P</th>
419
+ <th>720P</th>
420
+ </tr>
421
+ </thead>
422
+ <tbody>
423
+ <tr>
424
+ <td>flf2v-14B</td>
425
+ <td style="color: green;">❌</td>
426
+ <td style="color: green;">✔️</td>
427
+ <td>Wan2.1-FLF2V-14B-720P</td>
428
+ </tr>
429
+ </tbody>
430
+ </table>
431
+
432
+
433
+ ##### (1) Without Prompt Extension
434
+
435
+ - Single-GPU inference
436
+ ```sh
437
+ python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --prompt "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird’s feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
438
+ ```
439
+
440
+ > 💡Similar to Image-to-Video, the `size` parameter represents the area of the generated video, with the aspect ratio following that of the original input image.
441
+
442
+
443
+ - Multi-GPU inference using FSDP + xDiT USP
444
+
445
+ ```sh
446
+ pip install "xfuser>=0.4.1"
447
+ torchrun --nproc_per_node=8 generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --dit_fsdp --t5_fsdp --ulysses_size 8 --prompt "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird’s feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
448
+ ```
449
+
450
+ ##### (2) Using Prompt Extension
451
+
452
+
453
+ The process of prompt extension can be referenced [here](#2-using-prompt-extention).
454
+
455
+ Run with local prompt extension using `Qwen/Qwen2.5-VL-7B-Instruct`:
456
+ ```
457
+ python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --use_prompt_extend --prompt_extend_model Qwen/Qwen2.5-VL-7B-Instruct --prompt "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird’s feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
458
+ ```
459
+
460
+ Run with remote prompt extension using `dashscope`:
461
+ ```
462
+ DASH_API_KEY=your_key python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --use_prompt_extend --prompt_extend_method 'dashscope' --prompt "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird’s feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
463
+ ```
464
+
465
+
466
+ ##### (3) Running local gradio
467
+
468
+ ```sh
469
+ cd gradio
470
+ # use 720P model in gradio
471
+ DASH_API_KEY=your_key python flf2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-FLF2V-14B-720P
472
+ ```
473
+
474
+
475
+ #### Run VACE
476
+
477
+ [VACE](https://github.com/ali-vilab/VACE) now supports two models (1.3B and 14B) and two main resolutions (480P and 720P).
478
+ The input supports any resolution, but to achieve optimal results, the video size should fall within a specific range.
479
+ The parameters and configurations for these models are as follows:
480
+
481
+ <table>
482
+ <thead>
483
+ <tr>
484
+ <th rowspan="2">Task</th>
485
+ <th colspan="2">Resolution</th>
486
+ <th rowspan="2">Model</th>
487
+ </tr>
488
+ <tr>
489
+ <th>480P(~81x480x832)</th>
490
+ <th>720P(~81x720x1280)</th>
491
+ </tr>
492
+ </thead>
493
+ <tbody>
494
+ <tr>
495
+ <td>VACE</td>
496
+ <td style="color: green; text-align: center; vertical-align: middle;">✔️</td>
497
+ <td style="color: green; text-align: center; vertical-align: middle;">✔️</td>
498
+ <td>Wan2.1-VACE-14B</td>
499
+ </tr>
500
+ <tr>
501
+ <td>VACE</td>
502
+ <td style="color: green; text-align: center; vertical-align: middle;">✔️</td>
503
+ <td style="color: red; text-align: center; vertical-align: middle;">❌</td>
504
+ <td>Wan2.1-VACE-1.3B</td>
505
+ </tr>
506
+ </tbody>
507
+ </table>
508
+
509
+ In VACE, users can input text prompt and optional video, mask, and image for video generation or editing. Detailed instructions for using VACE can be found in the [User Guide](https://github.com/ali-vilab/VACE/blob/main/UserGuide.md).
510
+ The execution process is as follows:
511
+
512
+ ##### (1) Preprocessing
513
+
514
+ User-collected materials needs to be preprocessed into VACE-recognizable inputs, including `src_video`, `src_mask`, `src_ref_images`, and `prompt`.
515
+ For R2V (Reference-to-Video Generation), you may skip this preprocessing, but for V2V (Video-to-Video Editing) and MV2V (Masked Video-to-Video Editing) tasks, additional preprocessing is required to obtain video with conditions such as depth, pose or masked regions.
516
+ For more details, please refer to [vace_preproccess](https://github.com/ali-vilab/VACE/blob/main/vace/vace_preproccess.py).
517
+
518
+ ##### (2) cli inference
519
+
520
+ - Single-GPU inference
521
+ ```sh
522
+ python generate.py --task vace-1.3B --size 832*480 --ckpt_dir ./Wan2.1-VACE-1.3B --src_ref_images examples/girl.png,examples/snake.png --prompt "在一个欢乐而充满节日气氛的场景中,穿着鲜艳红色春���的小女孩正与她的可爱卡通蛇嬉戏。她的春服上绣着金色吉祥图案,散发着喜庆的气息,脸上洋溢着灿烂的笑容。蛇身呈现出亮眼的绿色,形状圆润,宽大的眼睛让它显得既友善又幽默。小女孩欢快地用手轻轻抚摸着蛇的头部,共同享受着这温馨的时刻。周围五彩斑斓的灯笼和彩带装饰着环境,阳光透过洒在她们身上,营造出一个充满友爱与幸福的新年氛围。"
523
+ ```
524
+
525
+ - Multi-GPU inference using FSDP + xDiT USP
526
+
527
+ ```sh
528
+ torchrun --nproc_per_node=8 generate.py --task vace-14B --size 1280*720 --ckpt_dir ./Wan2.1-VACE-14B --dit_fsdp --t5_fsdp --ulysses_size 8 --src_ref_images examples/girl.png,examples/snake.png --prompt "在一个欢乐而充满节日气氛的场景中,穿着鲜艳红色春服的小女孩正与她的可爱卡通蛇嬉戏。她的春服上绣着金色吉祥图案,散发着喜庆的气息,脸上洋溢着灿烂的笑容。蛇身呈现出亮眼的绿色,形状圆润,宽大的眼睛让它显得既友善又幽默。小女孩欢快地用手轻轻抚摸着蛇的头部,共同享受着这温馨的时刻。周围五彩斑斓的灯笼和彩带装饰着环境,阳光透过洒在她们身上,营造出一个充满友爱与幸福的新年氛围。"
529
+ ```
530
+
531
+ ##### (3) Running with Diffusers
532
+
533
+ You can easily inference **Wan2.1**-VACE using Diffusers with the following code:
534
+
535
+ ``` python
536
+ import torch
537
+ import PIL.Image
538
+ from diffusers import AutoencoderKLWan, WanVACEPipeline
539
+ from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler
540
+ from diffusers.utils import export_to_video, load_image
541
+
542
+
543
+ def prepare_video_and_mask(first_img: PIL.Image.Image, last_img: PIL.Image.Image, height: int, width: int, num_frames: int):
544
+ first_img = first_img.resize((width, height))
545
+ last_img = last_img.resize((width, height))
546
+ frames = []
547
+ frames.append(first_img)
548
+ # Ideally, this should be 127.5 to match original code, but they perform computation on numpy arrays
549
+ # whereas we are passing PIL images. If you choose to pass numpy arrays, you can set it to 127.5 to
550
+ # match the original code.
551
+ frames.extend([PIL.Image.new("RGB", (width, height), (128, 128, 128))] * (num_frames - 2))
552
+ frames.append(last_img)
553
+ mask_black = PIL.Image.new("L", (width, height), 0)
554
+ mask_white = PIL.Image.new("L", (width, height), 255)
555
+ mask = [mask_black, *[mask_white] * (num_frames - 2), mask_black]
556
+ return frames, mask
557
+
558
+
559
+ model_id = "/raid/aryan/diffusers-wan-vace-1.3b/"
560
+ vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
561
+ pipe = WanVACEPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
562
+ flow_shift = 5.0 # 5.0 for 720P, 3.0 for 480P
563
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
564
+ pipe.to("cuda")
565
+
566
+ prompt = "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird's feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."
567
+ negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"
568
+ first_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png")
569
+ last_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png")
570
+
571
+ height = 512
572
+ width = 512
573
+ num_frames = 81
574
+ video, mask = prepare_video_and_mask(first_frame, last_frame, height, width, num_frames)
575
+
576
+ output = pipe(
577
+ video=video,
578
+ mask=mask,
579
+ prompt=prompt,
580
+ negative_prompt=negative_prompt,
581
+ height=height,
582
+ width=width,
583
+ num_frames=num_frames,
584
+ num_inference_steps=30,
585
+ guidance_scale=5.0,
586
+ generator=torch.Generator().manual_seed(42),
587
+ ).frames[0]
588
+ export_to_video(output, "output.mp4", fps=16)
589
+ ```
590
+
591
+ Above is a demonstration of the First-Last-Frame-to-Video task. The code snippets available in [this](https://github.com/huggingface/diffusers/pull/11582) pull request demonstrate some more examples of how videos can be generated with different control signals.
592
+
593
+ For more details, check out the diffusers documentation for [Wan](https://huggingface.co/docs/diffusers/en/api/pipelines/wan).
594
+
595
+ ##### (4) Running local gradio
596
+ - Single-GPU inference
597
+ ```sh
598
+ python gradio/vace.py --ckpt_dir ./Wan2.1-VACE-1.3B
599
+ ```
600
+
601
+ - Multi-GPU inference using FSDP + xDiT USP
602
+ ```sh
603
+ python gradio/vace.py --mp --ulysses_size 8 --ckpt_dir ./Wan2.1-VACE-14B/
604
+ ```
605
+
606
+ #### Run Text-to-Image Generation
607
+
608
+ Wan2.1 is a unified model for both image and video generation. Since it was trained on both types of data, it can also generate images. The command for generating images is similar to video generation, as follows:
609
+
610
+ ##### (1) Without Prompt Extension
611
+
612
+ - Single-GPU inference
613
+ ```sh
614
+ python generate.py --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B --prompt '一个朴素端庄的美人'
615
+ ```
616
+
617
+ - Multi-GPU inference using FSDP + xDiT USP
618
+
619
+ ```sh
620
+ torchrun --nproc_per_node=8 generate.py --dit_fsdp --t5_fsdp --ulysses_size 8 --base_seed 0 --frame_num 1 --task t2i-14B --size 1024*1024 --prompt '一个朴素端庄的美人' --ckpt_dir ./Wan2.1-T2V-14B
621
+ ```
622
+
623
+ ##### (2) With Prompt Extention
624
+
625
+ - Single-GPU inference
626
+ ```sh
627
+ python generate.py --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B --prompt '一个朴素端庄的美人' --use_prompt_extend
628
+ ```
629
+
630
+ - Multi-GPU inference using FSDP + xDiT USP
631
+ ```sh
632
+ torchrun --nproc_per_node=8 generate.py --dit_fsdp --t5_fsdp --ulysses_size 8 --base_seed 0 --frame_num 1 --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B --prompt '一个朴素端庄的美人' --use_prompt_extend
633
+ ```
634
+
635
+
636
+ ## Manual Evaluation
637
+
638
+ ##### (1) Text-to-Video Evaluation
639
+
640
+ Through manual evaluation, the results generated after prompt extension are superior to those from both closed-source and open-source models.
641
+
642
+ <div align="center">
643
+ <img src="assets/t2v_res.jpg" alt="" style="width: 80%;" />
644
+ </div>
645
+
646
+
647
+ ##### (2) Image-to-Video Evaluation
648
+
649
+ We also conducted extensive manual evaluations to evaluate the performance of the Image-to-Video model, and the results are presented in the table below. The results clearly indicate that **Wan2.1** outperforms both closed-source and open-source models.
650
+
651
+ <div align="center">
652
+ <img src="assets/i2v_res.png" alt="" style="width: 80%;" />
653
+ </div>
654
+
655
+
656
+ ## Computational Efficiency on Different GPUs
657
+
658
+ We test the computational efficiency of different **Wan2.1** models on different GPUs in the following table. The results are presented in the format: **Total time (s) / peak GPU memory (GB)**.
659
+
660
+
661
+ <div align="center">
662
+ <img src="assets/comp_effic.png" alt="" style="width: 80%;" />
663
+ </div>
664
+
665
+ > The parameter settings for the tests presented in this table are as follows:
666
+ > (1) For the 1.3B model on 8 GPUs, set `--ring_size 8` and `--ulysses_size 1`;
667
+ > (2) For the 14B model on 1 GPU, use `--offload_model True`;
668
+ > (3) For the 1.3B model on a single 4090 GPU, set `--offload_model True --t5_cpu`;
669
+ > (4) For all testings, no prompt extension was applied, meaning `--use_prompt_extend` was not enabled.
670
+
671
+ > 💡Note: T2V-14B is slower than I2V-14B because the former samples 50 steps while the latter uses 40 steps.
672
+
673
+
674
+ -------
675
+
676
+ ## Introduction of Wan2.1
677
+
678
+ **Wan2.1** is designed on the mainstream diffusion transformer paradigm, achieving significant advancements in generative capabilities through a series of innovations. These include our novel spatio-temporal variational autoencoder (VAE), scalable training strategies, large-scale data construction, and automated evaluation metrics. Collectively, these contributions enhance the model’s performance and versatility.
679
+
680
+
681
+ ##### (1) 3D Variational Autoencoders
682
+ We propose a novel 3D causal VAE architecture, termed **Wan-VAE** specifically designed for video generation. By combining multiple strategies, we improve spatio-temporal compression, reduce memory usage, and ensure temporal causality. **Wan-VAE** demonstrates significant advantages in performance efficiency compared to other open-source VAEs. Furthermore, our **Wan-VAE** can encode and decode unlimited-length 1080P videos without losing historical temporal information, making it particularly well-suited for video generation tasks.
683
+
684
+
685
+ <div align="center">
686
+ <img src="assets/video_vae_res.jpg" alt="" style="width: 80%;" />
687
+ </div>
688
+
689
+
690
+ ##### (2) Video Diffusion DiT
691
+
692
+ **Wan2.1** is designed using the Flow Matching framework within the paradigm of mainstream Diffusion Transformers. Our model's architecture uses the T5 Encoder to encode multilingual text input, with cross-attention in each transformer block embedding the text into the model structure. Additionally, we employ an MLP with a Linear layer and a SiLU layer to process the input time embeddings and predict six modulation parameters individually. This MLP is shared across all transformer blocks, with each block learning a distinct set of biases. Our experimental findings reveal a significant performance improvement with this approach at the same parameter scale.
693
+
694
+ <div align="center">
695
+ <img src="assets/video_dit_arch.jpg" alt="" style="width: 80%;" />
696
+ </div>
697
+
698
+
699
+ | Model | Dimension | Input Dimension | Output Dimension | Feedforward Dimension | Frequency Dimension | Number of Heads | Number of Layers |
700
+ |--------|-----------|-----------------|------------------|-----------------------|---------------------|-----------------|------------------|
701
+ | 1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 |
702
+ | 14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
703
+
704
+
705
+
706
+ ##### Data
707
+
708
+ We curated and deduplicated a candidate dataset comprising a vast amount of image and video data. During the data curation process, we designed a four-step data cleaning process, focusing on fundamental dimensions, visual quality and motion quality. Through the robust data processing pipeline, we can easily obtain high-quality, diverse, and large-scale training sets of images and videos.
709
+
710
+ ![figure1](assets/data_for_diff_stage.jpg "figure1")
711
+
712
+
713
+ ##### Comparisons to SOTA
714
+ We compared **Wan2.1** with leading open-source and closed-source models to evaluate the performance. Using our carefully designed set of 1,035 internal prompts, we tested across 14 major dimensions and 26 sub-dimensions. We then compute the total score by performing a weighted calculation on the scores of each dimension, utilizing weights derived from human preferences in the matching process. The detailed results are shown in the table below. These results demonstrate our model's superior performance compared to both open-source and closed-source models.
715
+
716
+ ![figure1](assets/vben_vs_sota.png "figure1")
717
+
718
+
719
+ ## Citation
720
+ If you find our work helpful, please cite us.
721
+
722
+ ```
723
+ @article{wan2025,
724
+ title={Wan: Open and Advanced Large-Scale Video Generative Models},
725
+ author={Ang Wang and Baole Ai and Bin Wen and Chaojie Mao and Chen-Wei Xie and Di Chen and Feiwu Yu and Haiming Zhao and Jianxiao Yang and Jianyuan Zeng and Jiayu Wang and Jingfeng Zhang and Jingren Zhou and Jinkai Wang and Jixuan Chen and Kai Zhu and Kang Zhao and Keyu Yan and Lianghua Huang and Mengyang Feng and Ningyi Zhang and Pandeng Li and Pingyu Wu and Ruihang Chu and Ruili Feng and Shiwei Zhang and Siyang Sun and Tao Fang and Tianxing Wang and Tianyi Gui and Tingyu Weng and Tong Shen and Wei Lin and Wei Wang and Wei Wang and Wenmeng Zhou and Wente Wang and Wenting Shen and Wenyuan Yu and Xianzhong Shi and Xiaoming Huang and Xin Xu and Yan Kou and Yangyu Lv and Yifei Li and Yijing Liu and Yiming Wang and Yingya Zhang and Yitong Huang and Yong Li and You Wu and Yu Liu and Yulin Pan and Yun Zheng and Yuntao Hong and Yupeng Shi and Yutong Feng and Zeyinzi Jiang and Zhen Han and Zhi-Fan Wu and Ziyu Liu},
726
+ journal = {arXiv preprint arXiv:2503.20314},
727
+ year={2025}
728
+ }
729
+ ```
730
+
731
+ ## License Agreement
732
+ The models in this repository are licensed under the Apache 2.0 License. We claim no rights over the your generated contents, granting you the freedom to use them while ensuring that your usage complies with the provisions of this license. You are fully accountable for your use of the models, which must not involve sharing any content that violates applicable laws, causes harm to individuals or groups, disseminates personal information intended for harm, spreads misinformation, or targets vulnerable populations. For a complete list of restrictions and details regarding your rights, please refer to the full text of the [license](LICENSE.txt).
733
+
734
+
735
+ ## Acknowledgements
736
+
737
+ We would like to thank the contributors to the [SD3](https://huggingface.co/stabilityai/stable-diffusion-3-medium), [Qwen](https://huggingface.co/Qwen), [umt5-xxl](https://huggingface.co/google/umt5-xxl), [diffusers](https://github.com/huggingface/diffusers) and [HuggingFace](https://huggingface.co) repositories, for their open research.
738
+
739
+
740
+
741
+ ## Contact Us
742
+ If you would like to leave a message to our research or product teams, feel free to join our [Discord](https://discord.gg/AKNgpMK4Yj) or [WeChat groups](https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg)!