StevenZhang YiYiXu commited on
Commit
3d62c65
·
verified ·
1 Parent(s): 5539c13

add-read-me (#2)

Browse files

- add reaedme and assets (6bab4b49360ce1b8d55f936e746865bba86b7d79)


Co-authored-by: YiYi Xu <[email protected]>

.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/**/*.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/**/*.jpg filter=lfs diff=lfs merge=lfs -text
38
+ assets/**/*.jpeg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,246 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ # Wan2.1
5
+
6
+ <p align="center">
7
+ <img src="assets/logo.png" width="400"/>
8
+ <p>
9
+
10
+ <p align="center">
11
+ 💜 <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
12
+ <br>
13
+
14
+ -----
15
+
16
+ [**Wan: Open and Advanced Large-Scale Video Generative Models**](https://arxiv.org/abs/2503.20314) <be>
17
+
18
+ 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:
19
+ - 👍 **SOTA Performance**: **Wan2.1** consistently outperforms existing open-source models and state-of-the-art commercial solutions across multiple benchmarks.
20
+ - 👍 **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.
21
+ - 👍 **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.
22
+ - 👍 **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.
23
+ - 👍 **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.
24
+
25
+ ## Video Demos
26
+
27
+ <div align="center">
28
+ <video width="80%" controls>
29
+ <source src="https://cloud.video.taobao.com/vod/Jth64Y7wNoPcJki_Bo1ZJTDBvNjsgjlVKsNs05Fqfps.mp4" type="video/mp4">
30
+ Your browser does not support the video tag.
31
+ </video>
32
+ </div>
33
+
34
+ ## 🔥 Latest News!!
35
+
36
+ * Apr 17, 2025: 👋 We introduce **Wan2.1** [FLF2V](#run-first-last-frame-to-video-generation) with its inference code and weights!
37
+ * 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!
38
+ * 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!
39
+ * Feb 27, 2025: 👋 **Wan2.1** has been integrated into [ComfyUI](https://comfyanonymous.github.io/ComfyUI_examples/wan/). Enjoy!
40
+ * Feb 25, 2025: 👋 We've released the inference code and weights of **Wan2.1**.
41
+
42
+ ## Community Works
43
+ If your work has improved **Wan2.1** and you would like more people to see it, please inform us.
44
+ - [CFG-Zero](https://github.com/WeichenFan/CFG-Zero-star) enhances **Wan2.1** (covering both T2V and I2V models) from the perspective of CFG.
45
+ - [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!
46
+ - [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).
47
+
48
+
49
+ ## 📑 Todo List
50
+ - Wan2.1 Text-to-Video
51
+ - [x] Multi-GPU Inference code of the 14B and 1.3B models
52
+ - [x] Checkpoints of the 14B and 1.3B models
53
+ - [x] Gradio demo
54
+ - [x] ComfyUI integration
55
+ - [x] Diffusers integration
56
+ - [ ] Diffusers + Multi-GPU Inference
57
+ - Wan2.1 Image-to-Video
58
+ - [x] Multi-GPU Inference code of the 14B model
59
+ - [x] Checkpoints of the 14B model
60
+ - [x] Gradio demo
61
+ - [x] ComfyUI integration
62
+ - [x] Diffusers integration
63
+ - [ ] Diffusers + Multi-GPU Inference
64
+ - Wan2.1 First-Last-Frame-to-Video
65
+ - [x] Multi-GPU Inference code of the 14B model
66
+ - [x] Checkpoints of the 14B model
67
+ - [x] Gradio demo
68
+ - [ ] ComfyUI integration
69
+ - [x] Diffusers integration
70
+ - [ ] Diffusers + Multi-GPU Inference
71
+
72
+
73
+ ## 🚀 Quickstart
74
+
75
+ This repository corresponding to the diffusers format weights. You can find original release weights here: [Wan2.1-FLF2V-14B-720P](https://huggingface.co/Wan-AI/Wan2.1-FLF2V-14B-720P).
76
+
77
+ ### Using with diffusers
78
+
79
+ Make sure you upgrade to latest version of diffusers:
80
+ ```python
81
+ pip install git+https://github.com/huggingface/diffusers.git
82
+ ```
83
+ And then you can run:
84
+
85
+ ```python
86
+
87
+ import numpy as np
88
+ import torch
89
+ import torchvision.transforms.functional as TF
90
+ from diffusers import AutoencoderKLWan, WanImageToVideoPipeline
91
+ from diffusers.utils import export_to_video, load_image
92
+ from transformers import CLIPVisionModel
93
+
94
+ model_id = "Wan-AI/Wan2.1-FLF2V-14B-720P-Diffusers"
95
+ image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32)
96
+ vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
97
+ pipe = WanImageToVideoPipeline.from_pretrained(
98
+ model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
99
+ )
100
+ pipe.to("cuda")
101
+
102
+ first_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png")
103
+ last_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png")
104
+
105
+ def aspect_ratio_resize(image, pipe, max_area=720 * 1280):
106
+ aspect_ratio = image.height / image.width
107
+ mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
108
+ height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
109
+ width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
110
+ image = image.resize((width, height))
111
+ return image, height, width
112
+
113
+ def center_crop_resize(image, height, width):
114
+ # Calculate resize ratio to match first frame dimensions
115
+ resize_ratio = max(width / image.width, height / image.height)
116
+
117
+ # Resize the image
118
+ width = round(image.width * resize_ratio)
119
+ height = round(image.height * resize_ratio)
120
+ size = [width, height]
121
+ image = TF.center_crop(image, size)
122
+
123
+ return image, height, width
124
+
125
+ first_frame, height, width = aspect_ratio_resize(first_frame, pipe)
126
+ if last_frame.size != first_frame.size:
127
+ last_frame, _, _ = center_crop_resize(last_frame, height, width)
128
+
129
+ 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."
130
+
131
+ output = pipe(
132
+ image=first_frame, last_image=last_frame, prompt=prompt, height=height, width=width, guidance_scale=5.5
133
+ ).frames[0]
134
+ export_to_video(output, f"wan-ff2v.mp4", fps=16)
135
+ ```
136
+
137
+ > 💡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.
138
+
139
+
140
+ ## Manual Evaluation
141
+
142
+ ##### (1) Text-to-Video Evaluation
143
+
144
+ Through manual evaluation, the results generated after prompt extension are superior to those from both closed-source and open-source models.
145
+
146
+ <div align="center">
147
+ <img src="assets/t2v_res.jpg" alt="" style="width: 80%;" />
148
+ </div>
149
+
150
+
151
+ ##### (2) Image-to-Video Evaluation
152
+
153
+ 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.
154
+
155
+ <div align="center">
156
+ <img src="assets/i2v_res.png" alt="" style="width: 80%;" />
157
+ </div>
158
+
159
+
160
+ ## Computational Efficiency on Different GPUs
161
+
162
+ 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)**.
163
+
164
+
165
+ <div align="center">
166
+ <img src="assets/comp_effic.png" alt="" style="width: 80%;" />
167
+ </div>
168
+
169
+ > The parameter settings for the tests presented in this table are as follows:
170
+ > (1) For the 1.3B model on 8 GPUs, set `--ring_size 8` and `--ulysses_size 1`;
171
+ > (2) For the 14B model on 1 GPU, use `--offload_model True`;
172
+ > (3) For the 1.3B model on a single 4090 GPU, set `--offload_model True --t5_cpu`;
173
+ > (4) For all testings, no prompt extension was applied, meaning `--use_prompt_extend` was not enabled.
174
+
175
+ > 💡Note: T2V-14B is slower than I2V-14B because the former samples 50 steps while the latter uses 40 steps.
176
+
177
+
178
+ -------
179
+
180
+ ## Introduction of Wan2.1
181
+
182
+ **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.
183
+
184
+
185
+ ##### (1) 3D Variational Autoencoders
186
+ 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.
187
+
188
+
189
+ <div align="center">
190
+ <img src="assets/video_vae_res.jpg" alt="" style="width: 80%;" />
191
+ </div>
192
+
193
+
194
+ ##### (2) Video Diffusion DiT
195
+
196
+ **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.
197
+
198
+ <div align="center">
199
+ <img src="assets/video_dit_arch.jpg" alt="" style="width: 80%;" />
200
+ </div>
201
+
202
+
203
+ | Model | Dimension | Input Dimension | Output Dimension | Feedforward Dimension | Frequency Dimension | Number of Heads | Number of Layers |
204
+ |--------|-----------|-----------------|------------------|-----------------------|---------------------|-----------------|------------------|
205
+ | 1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 |
206
+ | 14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
207
+
208
+
209
+
210
+ ##### Data
211
+
212
+ 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.
213
+
214
+ ![figure1](assets/data_for_diff_stage.jpg "figure1")
215
+
216
+
217
+ ##### Comparisons to SOTA
218
+ 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.
219
+
220
+ ![figure1](assets/vben_vs_sota.png "figure1")
221
+
222
+
223
+ ## Citation
224
+ If you find our work helpful, please cite us.
225
+
226
+ ```
227
+ @article{wan2025,
228
+ title={Wan: Open and Advanced Large-Scale Video Generative Models},
229
+ author={WanTeam and 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},
230
+ journal = {arXiv preprint arXiv:2503.20314},
231
+ year={2025}
232
+ }
233
+ ```
234
+
235
+ ## License Agreement
236
+ 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).
237
+
238
+
239
+ ## Acknowledgements
240
+
241
+ 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.
242
+
243
+
244
+
245
+ ## Contact Us
246
+ 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)!
assets/comp_effic.png ADDED

Git LFS Details

  • SHA256: b0e225caffb4b31295ad150f95ee852e4c3dde4a00ac8f79a2ff500f2ce26b8d
  • Pointer size: 132 Bytes
  • Size of remote file: 1.79 MB
assets/data_for_diff_stage.jpg ADDED

Git LFS Details

  • SHA256: 59aec08409f2d46b0e640e4e120dc7cca52c08c3de56d026602dbcff1ebf241a
  • Pointer size: 131 Bytes
  • Size of remote file: 528 kB
assets/i2v_res.png ADDED

Git LFS Details

  • SHA256: 6823b3206d8d0cb18d3b5b949dec1217f1178109ba11f14e977b67e1f7b8a248
  • Pointer size: 131 Bytes
  • Size of remote file: 892 kB
assets/logo.png ADDED

Git LFS Details

  • SHA256: 96cddc0f667293436d0b9f92a299b6346b65b231d38ee49719a33d46c91fe1e3
  • Pointer size: 130 Bytes
  • Size of remote file: 56.3 kB
assets/t2v_res.jpg ADDED

Git LFS Details

  • SHA256: 91db579092446be2a834bc67721a8e4346936f38c4edb912f459ca3e10f8f439
  • Pointer size: 131 Bytes
  • Size of remote file: 301 kB
assets/vben_1.3b_vs_sota.png ADDED

Git LFS Details

  • SHA256: b7705db79f2e1428ec7a1e6fff8c4fbde062fb95bb233516ddbd04b20007c845
  • Pointer size: 131 Bytes
  • Size of remote file: 516 kB
assets/vben_vs_sota.png ADDED

Git LFS Details

  • SHA256: 9a0e86ca85046d2675f97984b88b6e74df07bba8a62a31ab8a1aef50d4eda44e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.55 MB
assets/video_dit_arch.jpg ADDED

Git LFS Details

  • SHA256: 195dceec6570289d8b01cc51d2e28a7786216f19de55b23978a52610d1646a66
  • Pointer size: 131 Bytes
  • Size of remote file: 643 kB
assets/video_vae_res.jpg ADDED

Git LFS Details

  • SHA256: d8f9e7f7353848056a615c8ef35ab86ec22976bb46cb27405008b4089701945c
  • Pointer size: 131 Bytes
  • Size of remote file: 213 kB