Julian Bilcke commited on
Commit ·
1f16b57
1
Parent(s): 15e3600
test
Browse filesFiles changed (11)
- .claude/settings.local.jsonAdded+3
- Dockerfile+1-1
- degraded_finetrainers_requirements.txt+4-4
- degraded_requirements.txt+1-1
- docs/wan/README-for-Wan2.1-FLF2V-14B-720P-diffusers.mdAdded+246
- docs/wan/README-for-Wan2.1-I2V-14B-480P-diffusers.mdAdded+310
- docs/wan/README-for-Wan2.1-I2V-14B-720P-diffusers.mdAdded+311
- requirements.txt+7-2
- vms/config.py+5
- vms/ui/project/services/previewing.py+79-34
- vms/ui/project/tabs/preview_tab.py+35-9
123{ "enableAllProjectMcpServers": false}1234FROM nvidia/cuda:12.4.0-devel-ubuntu22.04# Prevent interactive prompts during buildARG DEBIAN_FRONTEND=noninteractive1234FROM nvidia/cuda:12.8.1-devel-ubuntu24.04# Prevent interactive prompts during buildARG DEBIAN_FRONTEND=noninteractive
8 unmodified lines91011121314151617188 unmodified lines#decord>=0.6.0wandbpandastorch>=2.5.1torchvision>=0.20.1torchdata>=0.10.1torchao>=0.7.0sentencepiece>=0.2.0imageio-ffmpeg>=0.5.1numpy>=1.26.48 unmodified lines91011121314151617188 unmodified lines#decord>=0.6.0wandbpandastorch==2.6.0torchvision==0.21.0torchdata==0.1.0torchao==0.9.0sentencepiece>=0.2.0imageio-ffmpeg>=0.5.1numpy>=1.26.4
14 unmodified lines1516171819202114 unmodified lineseva-decord# don't install flash attention on macOS#flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl#--------------- / MACOS HACKS --------------14 unmodified lines1516171819202114 unmodified lineseva-decord# don't install flash attention on macOS#flash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl#--------------- / MACOS HACKS --------------
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246---
license: apache-2.0
---
# Wan2.1
<p align="center">
<img src="assets/logo.png" width="400"/>
<p>
<p align="center">
💜 <a href="https://wan.video"><b>Wan</b></a>    |    🖥️ <a href="https://github.com/Wan-Video/Wan2.1">GitHub</a>    |   🤗 <a href="https://huggingface.co/Wan-AI/">Hugging Face</a>   |   🤖 <a href="https://modelscope.cn/organization/Wan-AI">ModelScope</a>   |    📑 <a href="https://arxiv.org/abs/2503.20314">Technical Report</a>    |    📑 <a href="https://wan.video/welcome?spm=a2ty_o02.30011076.0.0.6c9ee41eCcluqg">Blog</a>    |   💬 <a href="https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg">WeChat Group</a>   |    📖 <a href="https://discord.gg/AKNgpMK4Yj">Discord</a>  
<br>
-----
[**Wan: Open and Advanced Large-Scale Video Generative Models**](https://arxiv.org/abs/2503.20314) <be>
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:
- 👍 **SOTA Performance**: **Wan2.1** consistently outperforms existing open-source models and state-of-the-art commercial solutions across multiple benchmarks.
- 👍 **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.
- 👍 **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.
- 👍 **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.
- 👍 **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.
## Video Demos
<div align="center">
<video width="80%" controls>
<source src="https://cloud.video.taobao.com/vod/Jth64Y7wNoPcJki_Bo1ZJTDBvNjsgjlVKsNs05Fqfps.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
## 🔥 Latest News!!
* Apr 17, 2025: 👋 We introduce **Wan2.1** [FLF2V](#run-first-last-frame-to-video-generation) with its inference code and weights!
* 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!
* 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!
* Feb 27, 2025: 👋 **Wan2.1** has been integrated into [ComfyUI](https://comfyanonymous.github.io/ComfyUI_examples/wan/). Enjoy!
* Feb 25, 2025: 👋 We've released the inference code and weights of **Wan2.1**.
## Community Works
If your work has improved **Wan2.1** and you would like more people to see it, please inform us.
- [CFG-Zero](https://github.com/WeichenFan/CFG-Zero-star) enhances **Wan2.1** (covering both T2V and I2V models) from the perspective of CFG.
- [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!
- [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).
## 📑 Todo List
- Wan2.1 Text-to-Video
- [x] Multi-GPU Inference code of the 14B and 1.3B models
- [x] Checkpoints of the 14B and 1.3B models
- [x] Gradio demo
- [x] ComfyUI integration
- [x] Diffusers integration
- [ ] Diffusers + Multi-GPU Inference
- Wan2.1 Image-to-Video
- [x] Multi-GPU Inference code of the 14B model
- [x] Checkpoints of the 14B model
- [x] Gradio demo
- [x] ComfyUI integration
- [x] Diffusers integration
- [ ] Diffusers + Multi-GPU Inference
- Wan2.1 First-Last-Frame-to-Video
- [x] Multi-GPU Inference code of the 14B model
- [x] Checkpoints of the 14B model
- [x] Gradio demo
- [ ] ComfyUI integration
- [x] Diffusers integration
- [ ] Diffusers + Multi-GPU Inference
## 🚀 Quickstart
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).
### Using with diffusers
Make sure you upgrade to latest version of diffusers:
```python
pip install git+https://github.com/huggingface/diffusers.git
```
And then you can run:
```python
import numpy as np
import torch
import torchvision.transforms.functional as TF
from diffusers import AutoencoderKLWan, WanImageToVideoPipeline
from diffusers.utils import export_to_video, load_image
from transformers import CLIPVisionModel
model_id = "Wan-AI/Wan2.1-FLF2V-14B-720P-Diffusers"
image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32)
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanImageToVideoPipeline.from_pretrained(
model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16
)
pipe.to("cuda")
first_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png")
last_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png")
def aspect_ratio_resize(image, pipe, max_area=720 * 1280):
aspect_ratio = image.height / image.width
mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
image = image.resize((width, height))
return image, height, width
def center_crop_resize(image, height, width):
# Calculate resize ratio to match first frame dimensions
resize_ratio = max(width / image.width, height / image.height)
# Resize the image
width = round(image.width * resize_ratio)
height = round(image.height * resize_ratio)
size = [width, height]
image = TF.center_crop(image, size)
return image, height, width
first_frame, height, width = aspect_ratio_resize(first_frame, pipe)
if last_frame.size != first_frame.size:
last_frame, _, _ = center_crop_resize(last_frame, height, width)
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."
output = pipe(
image=first_frame, last_image=last_frame, prompt=prompt, height=height, width=width, guidance_scale=5.5
).frames[0]
export_to_video(output, f"wan-ff2v.mp4", fps=16)
```
> 💡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.
## Manual Evaluation
##### (1) Text-to-Video Evaluation
Through manual evaluation, the results generated after prompt extension are superior to those from both closed-source and open-source models.
<div align="center">
<img src="assets/t2v_res.jpg" alt="" style="width: 80%;" />
</div>
##### (2) Image-to-Video Evaluation
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.
<div align="center">
<img src="assets/i2v_res.png" alt="" style="width: 80%;" />
</div>
## Computational Efficiency on Different GPUs
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)**.
<div align="center">
<img src="assets/comp_effic.png" alt="" style="width: 80%;" />
</div>
> The parameter settings for the tests presented in this table are as follows:
> (1) For the 1.3B model on 8 GPUs, set `--ring_size 8` and `--ulysses_size 1`;
> (2) For the 14B model on 1 GPU, use `--offload_model True`;
> (3) For the 1.3B model on a single 4090 GPU, set `--offload_model True --t5_cpu`;
> (4) For all testings, no prompt extension was applied, meaning `--use_prompt_extend` was not enabled.
> 💡Note: T2V-14B is slower than I2V-14B because the former samples 50 steps while the latter uses 40 steps.
-------
## Introduction of Wan2.1
**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.
##### (1) 3D Variational Autoencoders
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.
<div align="center">
<img src="assets/video_vae_res.jpg" alt="" style="width: 80%;" />
</div>
##### (2) Video Diffusion DiT
**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.
<div align="center">
<img src="assets/video_dit_arch.jpg" alt="" style="width: 80%;" />
</div>
| Model | Dimension | Input Dimension | Output Dimension | Feedforward Dimension | Frequency Dimension | Number of Heads | Number of Layers |
|--------|-----------|-----------------|------------------|-----------------------|---------------------|-----------------|------------------|
| 1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 |
| 14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
##### Data
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.

##### Comparisons to SOTA
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.

## Citation
If you find our work helpful, please cite us.
```
@article{wan2025,
title={Wan: Open and Advanced Large-Scale Video Generative Models},
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},
journal = {arXiv preprint arXiv:2503.20314},
year={2025}
}
```
## License Agreement
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).
## Acknowledgements
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.
## Contact Us
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)!123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310---license: apache-2.0language:- en- zhpipeline_tag: image-to-videolibrary_name: diffuserstags:- video- video-generation---# Wan2.1
<p align="center"> <img src="assets/logo.png" width="400"/><p>
<p align="center"> 💜 <a href=""><b>Wan</b></a>    |    🖥️ <a href="https://github.com/Wan-Video/Wan2.1">GitHub</a>    |   🤗 <a href="https://huggingface.co/Wan-AI/">Hugging Face</a>   |   🤖 <a href="https://modelscope.cn/organization/Wan-AI">ModelScope</a>   |    📑 <a href="">Paper (Coming soon)</a>    |    📑 <a href="https://wanxai.com">Blog</a>    |   💬 <a href="https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg">WeChat Group</a>   |    📖 <a href="https://discord.gg/p5XbdQV7">Discord</a>  <br>
-----
[**Wan: Open and Advanced Large-Scale Video Generative Models**]() <be>
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:- 👍 **SOTA Performance**: **Wan2.1** consistently outperforms existing open-source models and state-of-the-art commercial solutions across multiple benchmarks.- 👍 **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.- 👍 **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.- 👍 **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.- 👍 **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.
This repo contains our I2V-14B model, which is capable of generating 480P videos, offering advantages in terms of fast generation and excellent quality.
## Video Demos
<div align="center"> <video width="80%" controls> <source src="https://cloud.video.taobao.com/vod/Jth64Y7wNoPcJki_Bo1ZJTDBvNjsgjlVKsNs05Fqfps.mp4" type="video/mp4"> Your browser does not support the video tag. </video></div>
## 🔥 Latest News!!
* Feb 25, 2025: 👋 We've released the inference code and weights of Wan2.1.
## 📑 Todo List- Wan2.1 Text-to-Video - [x] Multi-GPU Inference code of the 14B and 1.3B models - [x] Checkpoints of the 14B and 1.3B models - [x] Gradio demo - [x] Diffusers integration - [ ] ComfyUI integration- Wan2.1 Image-to-Video - [x] Multi-GPU Inference code of the 14B model - [x] Checkpoints of the 14B model - [x] Gradio demo - [x] Diffusers integration - [ ] ComfyUI integration
## Quickstart
#### InstallationClone the repo:```git clone https://github.com/Wan-Video/Wan2.1.gitcd Wan2.1```
Install dependencies:```# Ensure torch >= 2.4.0pip install -r requirements.txt```
#### Model Download
| Models | Download Link | Notes || --------------|-------------------------------------------------------------------------------|-------------------------------|| 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| 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| 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| 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
> 💡Note: 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.
Download models using 🤗 huggingface-cli:```pip install "huggingface_hub[cli]"huggingface-cli download Wan-AI/Wan2.1-I2V-14B-480P-Diffusers --local-dir ./Wan2.1-I2V-14B-480P-Diffusers```
Download models using 🤖 modelscope-cli:```pip install modelscopemodelscope download Wan-AI/Wan2.1-I2V-14B-480P-Diffusers --local_dir ./Wan2.1-I2V-14B-480P-Diffusers```
#### Run Image-to-Video Generation
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:<table> <thead> <tr> <th rowspan="2">Task</th> <th colspan="2">Resolution</th> <th rowspan="2">Model</th> </tr> <tr> <th>480P</th> <th>720P</th> </tr> </thead> <tbody> <tr> <td>i2v-14B</td> <td style="color: green;">❌</td> <td style="color: green;">✔️</td> <td>Wan2.1-I2V-14B-720P</td> </tr> <tr> <td>i2v-14B</td> <td style="color: green;">✔️</td> <td style="color: red;">❌</td> <td>Wan2.1-T2V-14B-480P</td> </tr> </tbody></table>
##### (1) Without Prompt Extention
- Single-GPU inference```python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --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."```
> 💡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.
- Multi-GPU inference using FSDP + xDiT USP
```pip install "xfuser>=0.4.1"torchrun --nproc_per_node=8 generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --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."```
Wan can also be run directly using 🤗 Diffusers!
```pythonimport torchimport numpy as npfrom diffusers import AutoencoderKLWan, WanImageToVideoPipelinefrom diffusers.utils import export_to_video, load_imagefrom transformers import CLIPVisionModel
# Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusersmodel_id = "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers"image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32)vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)pipe = WanImageToVideoPipeline.from_pretrained(model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16)pipe.to("cuda")
image = load_image( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg")max_area = 480 * 832aspect_ratio = image.height / image.widthmod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_valuewidth = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_valueimage = image.resize((width, height))prompt = ( "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in " "the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.")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"
output = pipe( image=image, prompt=prompt, negative_prompt=negative_prompt, height=height, width=width, num_frames=81, guidance_scale=5.0).frames[0]export_to_video(output, "output.mp4", fps=16)```
##### (2) Using Prompt Extention
Run with local prompt extention using `Qwen/Qwen2.5-VL-7B-Instruct`:```python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --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."```
Run with remote prompt extention using `dashscope`:```DASH_API_KEY=your_key python generate.py --task i2v-14B --size 832*480 --ckpt_dir ./Wan2.1-I2V-14B-480P --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."```
##### (3) Runing local gradio
```cd gradio# if one only uses 480P model in gradioDASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P
# if one only uses 720P model in gradioDASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
# if one uses both 480P and 720P models in gradioDASH_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```
## Manual Evaluation
We 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.
<div align="center"> <img src="assets/i2v_res.png" alt="" style="width: 80%;" /></div>
## Computational Efficiency on Different GPUs
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)**.
<div align="center"> <img src="assets/comp_effic.png" alt="" style="width: 80%;" /></div>
> The parameter settings for the tests presented in this table are as follows:> (1) For the 1.3B model on 8 GPUs, set `--ring_size 8` and `--ulysses_size 1`;> (2) For the 14B model on 1 GPU, use `--offload_model True`;> (3) For the 1.3B model on a single 4090 GPU, set `--offload_model True --t5_cpu`;> (4) For all testings, no prompt extension was applied, meaning `--use_prompt_extend` was not enabled.
-------
## Introduction of Wan2.1
**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.
##### (1) 3D Variational AutoencodersWe 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.
<div align="center"> <img src="assets/video_vae_res.jpg" alt="" style="width: 80%;" /></div>
##### (2) Video Diffusion DiT
**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.
<div align="center"> <img src="assets/video_dit_arch.jpg" alt="" style="width: 80%;" /></div>
| Model | Dimension | Input Dimension | Output Dimension | Feedforward Dimension | Frequency Dimension | Number of Heads | Number of Layers ||--------|-----------|-----------------|------------------|-----------------------|---------------------|-----------------|------------------|| 1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 || 14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
##### Data
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.

##### Comparisons to SOTAWe compared **Wan2.1** with leading open-source and closed-source models to evaluate the performace. 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.

## CitationIf you find our work helpful, please cite us.
```@article{wan2.1, title = {Wan: Open and Advanced Large-Scale Video Generative Models}, author = {Wan Team}, journal = {}, year = {2025}}```
## License AgreementThe models in this repository are licensed under the Apache 2.0 License. We claim no rights over the your generate 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).
## Acknowledgements
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.
## Contact UsIf you would like to leave a message to our research or product teams, feel free to join our [Discord](https://discord.gg/p5XbdQV7) or [WeChat groups](https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg)!123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311---license: apache-2.0language:- en- zhpipeline_tag: image-to-videolibrary_name: diffuserstags:- video- video genration---# Wan2.1
<p align="center"> <img src="assets/logo.png" width="400"/><p>
<p align="center"> 💜 <a href=""><b>Wan</b></a>    |    🖥️ <a href="https://github.com/Wan-Video/Wan2.1">GitHub</a>    |   🤗 <a href="https://huggingface.co/Wan-AI/">Hugging Face</a>   |   🤖 <a href="https://modelscope.cn/organization/Wan-AI">ModelScope</a>   |    📑 <a href="">Paper (Coming soon)</a>    |    📑 <a href="https://wanxai.com">Blog</a>    |   💬 <a href="https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg">WeChat Group</a>   |    📖 <a href="https://discord.gg/p5XbdQV7">Discord</a>  <br>
-----
[**Wan: Open and Advanced Large-Scale Video Generative Models**]() <be>
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:- 👍 **SOTA Performance**: **Wan2.1** consistently outperforms existing open-source models and state-of-the-art commercial solutions across multiple benchmarks.- 👍 **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.- 👍 **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.- 👍 **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.- 👍 **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.
This repository contains our I2V-14B model, which is capable of generating 720P high-definition videos. After thousands of rounds of human evaluations, this model has outperformed both closed-source and open-source alternatives, achieving state-of-the-art performance.
## Video Demos
<div align="center"> <video width="80%" controls> <source src="https://cloud.video.taobao.com/vod/Jth64Y7wNoPcJki_Bo1ZJTDBvNjsgjlVKsNs05Fqfps.mp4" type="video/mp4"> Your browser does not support the video tag. </video></div>
## 🔥 Latest News!!
* Feb 25, 2025: 👋 We've released the inference code and weights of Wan2.1.
## 📑 Todo List- Wan2.1 Text-to-Video - [x] Multi-GPU Inference code of the 14B and 1.3B models - [x] Checkpoints of the 14B and 1.3B models - [x] Gradio demo - [x] Diffusers integration - [ ] ComfyUI integration- Wan2.1 Image-to-Video - [x] Multi-GPU Inference code of the 14B model - [x] Checkpoints of the 14B model - [x] Gradio demo - [x] Diffusers integration - [ ] ComfyUI integration
## Quickstart
#### InstallationClone the repo:```git clone https://github.com/Wan-Video/Wan2.1.gitcd Wan2.1```
Install dependencies:```# Ensure torch >= 2.4.0pip install -r requirements.txt```
#### Model Download
| Models | Download Link | Notes || --------------|-------------------------------------------------------------------------------|-------------------------------|| 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| 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| 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| 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
> 💡Note: 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.
Download models using 🤗 huggingface-cli:```pip install "huggingface_hub[cli]"huggingface-cli download Wan-AI/Wan2.1-I2V-14B-720P-Diffusers --local-dir ./Wan2.1-I2V-14B-720P-Diffusers```
Download models using 🤖 modelscope-cli:```pip install modelscopemodelscope download Wan-AI/Wan2.1-I2V-14B-720P-Diffusers --local_dir ./Wan2.1-I2V-14B-720P-Diffusers```
#### Run Image-to-Video Generation
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:<table> <thead> <tr> <th rowspan="2">Task</th> <th colspan="2">Resolution</th> <th rowspan="2">Model</th> </tr> <tr> <th>480P</th> <th>720P</th> </tr> </thead> <tbody> <tr> <td>i2v-14B</td> <td style="color: green;">❌</td> <td style="color: green;">✔️</td> <td>Wan2.1-I2V-14B-720P</td> </tr> <tr> <td>i2v-14B</td> <td style="color: green;">✔️</td> <td style="color: red;">❌</td> <td>Wan2.1-T2V-14B-480P</td> </tr> </tbody></table>
##### (1) Without Prompt Extention
- Single-GPU inference```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."```
> 💡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.
- Multi-GPU inference using FSDP + xDiT USP
```pip install "xfuser>=0.4.1"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."```
Wan can also be run directly using 🤗 Diffusers!
```pythonimport torchimport numpy as npfrom diffusers import AutoencoderKLWan, WanImageToVideoPipelinefrom diffusers.utils import export_to_video, load_imagefrom transformers import CLIPVisionModel
# Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusersmodel_id = "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers"image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32)vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)pipe = WanImageToVideoPipeline.from_pretrained(model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16)pipe.to("cuda")
image = load_image( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg")max_area = 720 * 1280aspect_ratio = image.height / image.widthmod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_valuewidth = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_valueimage = image.resize((width, height))prompt = ( "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in " "the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.")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"
output = pipe( image=image, prompt=prompt, negative_prompt=negative_prompt, height=height, width=width, num_frames=81, guidance_scale=5.0).frames[0]export_to_video(output, "output.mp4", fps=16)```
##### (2) Using Prompt Extention
Run with local prompt extention using `Qwen/Qwen2.5-VL-7B-Instruct`:```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."```
Run with remote prompt extention using `dashscope`:```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."```
##### (3) Runing local gradio
```cd gradio# if one only uses 480P model in gradioDASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P
# if one only uses 720P model in gradioDASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
# if one uses both 480P and 720P models in gradioDASH_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```
## Manual Evaluation
We 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.
<div align="center"> <img src="assets/i2v_res.png" alt="" style="width: 80%;" /></div>
## Computational Efficiency on Different GPUs
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)**.
<div align="center"> <img src="assets/comp_effic.png" alt="" style="width: 80%;" /></div>
> The parameter settings for the tests presented in this table are as follows:> (1) For the 1.3B model on 8 GPUs, set `--ring_size 8` and `--ulysses_size 1`;> (2) For the 14B model on 1 GPU, use `--offload_model True`;> (3) For the 1.3B model on a single 4090 GPU, set `--offload_model True --t5_cpu`;> (4) For all testings, no prompt extension was applied, meaning `--use_prompt_extend` was not enabled.
-------
## Introduction of Wan2.1
**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.
##### (1) 3D Variational AutoencodersWe 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.
<div align="center"> <img src="assets/video_vae_res.jpg" alt="" style="width: 80%;" /></div>
##### (2) Video Diffusion DiT
**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.
<div align="center"> <img src="assets/video_dit_arch.jpg" alt="" style="width: 80%;" /></div>
| Model | Dimension | Input Dimension | Output Dimension | Feedforward Dimension | Frequency Dimension | Number of Heads | Number of Layers ||--------|-----------|-----------------|------------------|-----------------------|---------------------|-----------------|------------------|| 1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 || 14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
##### Data
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.

##### Comparisons to SOTAWe compared **Wan2.1** with leading open-source and closed-source models to evaluate the performace. 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.

## CitationIf you find our work helpful, please cite us.
```@article{wan2.1, title = {Wan: Open and Advanced Large-Scale Video Generative Models}, author = {Wan Team}, journal = {}, year = {2025}}```
## License AgreementThe models in this repository are licensed under the Apache 2.0 License. We claim no rights over the your generate 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).
## Acknowledgements
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.
## Contact UsIf you would like to leave a message to our research or product teams, feel free to join our [Discord](https://discord.gg/p5XbdQV7) or [WeChat groups](https://gw.alicdn.com/imgextra/i2/O1CN01tqjWFi1ByuyehkTSB_!!6000000000015-0-tps-611-1279.jpg)!123410 unmodified lines15161718192021# For GPU monitoring of NVIDIA chipsetspynvml10 unmodified linesimageioimageio-ffmpegflash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl# for youtube video downloadpytube12345678910 unmodified lines20212223242526# we don't have a flash attention binary yet for Pytorch 2.7# so we use pytorch 2.6torch==2.6.0torchvision==0.21.0torchdata==0.1.0torchao==0.9.0# For GPU monitoring of NVIDIA chipsetspynvml10 unmodified linesimageioimageio-ffmpegflash-attn @ https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl# for youtube video downloadpytube
231 unmodified lines232233234235236237231 unmodified lines"name": "Wan 2.1 I2V 720p (image+text)","type": "image-to-video","description": "Image conditioning at 720p resolution"}},"ltx_video": {231 unmodified lines232233234235236237238239240241242231 unmodified lines"name": "Wan 2.1 I2V 720p (image+text)","type": "image-to-video","description": "Image conditioning at 720p resolution"},"Wan-AI/Wan2.1-FLF2V-14B-720P-diffusers": {"name": "Wan 2.1 FLF2V 720p (frame conditioning)","type": "frame-to-video","description": "Frame conditioning (first/last frame to video) at 720p resolution"}},"ltx_video": {
77 unmodified lines7879808182838464 unmodified lines14915015115215315415515615715811 unmodified lines17017117217317417517633 unmodified lines21021121221321421521621721821922022122222322422515 unmodified lines24124224324424524624724824925025125225325425525625716 unmodified lines27427527627727827928028128228328428528628728828929029129229329429529629729829930077 unmodified linesseed: int = -1,enable_cpu_offload: bool = True,fps: int = 16,conditioning_image: Optional[str] = None) -> Tuple[Optional[str], str, str]:"""Generate a video using the trained model"""try:64 unmodified linesmodel_version = "hunyuanvideo-community/HunyuanVideo"log(f"No versions defined for model type, using default: {model_version}")# Check if this is an image-to-video model but no image was providedmodel_version_info = versions.get(model_version, {})if model_version_info.get("type") == "image-to-video" and not conditioning_image:return None, "Error: This model requires a conditioning image", log("Error: This model version requires a conditioning image but none was provided")log(f"Generating video with model type: {internal_model_type}")log(f"Using model version: {model_version}")11 unmodified linesfull_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_scale,inference_steps, seed, enable_cpu_offload, fps, log,model_version, conditioning_image)elif internal_model_type == "ltx_video":return self.generate_ltx_video(33 unmodified linesfps: int = 16,log_fn: Callable = print,model_version: str = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers",conditioning_image: Optional[str] = None) -> Tuple[Optional[str], str, str]:"""Generate video using Wan model"""try:import torchimport numpy as npfrom diffusers import AutoencoderKLWan, WanPipelinefrom diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepSchedulerfrom diffusers.utils import export_to_videofrom PIL import Imageimport os15 unmodified linesgenerator = torch.Generator(device="cuda")generator = generator.manual_seed(seed)log_fn(f"Loading VAE from {model_version}...")vae = AutoencoderKLWan.from_pretrained(model_version, subfolder="vae", torch_dtype=torch.float32)log_fn(f"Loading transformer from {model_version}...")pipe = WanPipeline.from_pretrained(model_version, vae=vae, torch_dtype=torch.bfloat16)log_fn(f"Configuring scheduler with flow_shift={flow_shift}...")pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config,flow_shift=flow_shift)log_fn("Moving pipeline to CUDA device...")pipe.to("cuda")16 unmodified lineslog_fn("Starting video generation...")start_time.record()# Check if this is an image-to-video modelis_i2v = "I2V" in model_versionif is_i2v and conditioning_image:log_fn(f"Loading conditioning image from {conditioning_image}...")image = Image.open(conditioning_image).convert("RGB")image = image.resize((width, height))log_fn("Generating video with image conditioning...")output = pipe(prompt=prompt,negative_prompt=negative_prompt,image=image,height=height,width=width,num_frames=num_frames,guidance_scale=guidance_scale,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]else:log_fn("Generating video with text-only conditioning...")output = pipe(77 unmodified lines787980818283848564 unmodified lines15015115215315415515615715815916016116216316411 unmodified lines17617717817918018118233 unmodified lines21621721821922022122222322422522622722822923023123223315 unmodified lines24925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928016 unmodified lines29729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434577 unmodified linesseed: int = -1,enable_cpu_offload: bool = True,fps: int = 16,first_frame_image: Optional[str] = None,last_frame_image: Optional[str] = None) -> Tuple[Optional[str], str, str]:"""Generate a video using the trained model"""try:64 unmodified linesmodel_version = "hunyuanvideo-community/HunyuanVideo"log(f"No versions defined for model type, using default: {model_version}")# Check if this is an image-to-video or frame-to-video model but no image was providedmodel_version_info = versions.get(model_version, {})if model_version_info.get("type") in ["image-to-video", "frame-to-video"] and not first_frame_image:model_type_name = "frame conditioning" if model_version_info.get("type") == "frame-to-video" else "conditioning"return None, f"Error: This model requires a {model_type_name} image", log(f"Error: This model version requires a {model_type_name} image but none was provided")# Additional check for FLF2V models that require both first and last frameif model_version_info.get("type") == "frame-to-video" and first_frame_image and not last_frame_image:return None, "Error: FLF2V models require both first and last frame images", log("Error: FLF2V models require both first and last frame images but only first frame was provided")log(f"Generating video with model type: {internal_model_type}")log(f"Using model version: {model_version}")11 unmodified linesfull_prompt, negative_prompt, width, height, num_frames,guidance_scale, flow_shift, lora_path, lora_scale,inference_steps, seed, enable_cpu_offload, fps, log,model_version, first_frame_image, last_frame_image)elif internal_model_type == "ltx_video":return self.generate_ltx_video(33 unmodified linesfps: int = 16,log_fn: Callable = print,model_version: str = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers",first_frame_image: Optional[str] = None,last_frame_image: Optional[str] = None) -> Tuple[Optional[str], str, str]:"""Generate video using Wan model"""try:import torchimport numpy as npfrom diffusers import AutoencoderKLWan, WanPipeline, WanImageToVideoPipelinefrom diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepSchedulerfrom diffusers.utils import export_to_videofrom transformers import CLIPVisionModelfrom PIL import Imageimport os15 unmodified linesgenerator = torch.Generator(device="cuda")generator = generator.manual_seed(seed)# Check if this is an I2V or FLF2V model that requires WanImageToVideoPipelineis_i2v = "I2V" in model_versionis_flf2v = "FLF2V" in model_versionuses_image_pipeline = is_i2v or is_flf2vlog_fn(f"Loading VAE from {model_version}...")vae = AutoencoderKLWan.from_pretrained(model_version, subfolder="vae", torch_dtype=torch.float32)if uses_image_pipeline:model_type_str = "FLF2V" if is_flf2v else "I2V"log_fn(f"Loading image encoder for {model_type_str} model from {model_version}...")image_encoder = CLIPVisionModel.from_pretrained(model_version, subfolder="image_encoder", torch_dtype=torch.float32)log_fn(f"Loading WanImageToVideoPipeline from {model_version}...")pipe = WanImageToVideoPipeline.from_pretrained(model_version, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16)else:log_fn(f"Loading WanPipeline from {model_version}...")pipe = WanPipeline.from_pretrained(model_version, vae=vae, torch_dtype=torch.bfloat16)log_fn(f"Configuring scheduler with flow_shift={flow_shift}...")pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config,flow_shift=flow_shift)log_fn("Moving pipeline to CUDA device...")pipe.to("cuda")16 unmodified lineslog_fn("Starting video generation...")start_time.record()# Generate video based on model typeif (is_i2v or is_flf2v) and first_frame_image:log_fn(f"Loading first frame image from {first_frame_image}...")first_frame = Image.open(first_frame_image).convert("RGB")first_frame = first_frame.resize((width, height))if is_flf2v:log_fn("Generating video with frame conditioning (FLF2V)...")if not last_frame_image:return None, "Error: FLF2V model requires both first and last frame images", log_fn("Error: FLF2V model requires both first and last frame images")log_fn(f"Loading last frame image from {last_frame_image}...")last_frame = Image.open(last_frame_image).convert("RGB")last_frame = last_frame.resize((width, height))output = pipe(prompt=prompt,negative_prompt=negative_prompt,image=first_frame,last_image=last_frame,height=height,width=width,num_frames=num_frames,guidance_scale=guidance_scale,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]else:log_fn("Generating video with image conditioning...")output = pipe(prompt=prompt,negative_prompt=negative_prompt,image=first_frame,height=height,width=width,num_frames=num_frames,guidance_scale=guidance_scale,num_inference_steps=inference_steps,cross_attention_kwargs={"scale": lora_scale},generator=generator,).frames[0]else:log_fn("Generating video with text-only conditioning...")output = pipe(
102 unmodified lines103104105106107108109110260 unmodified lines37137237337437537637759 unmodified lines4374384394404414424438 unmodified lines452453454455456457458459460461462144 unmodified lines60760860961061161261361 unmodified lines675676677678679680681102 unmodified lines)# Add image input for image-to-video modelsself.components["conditioning_image"] = gr.Image(label="Conditioning Image (for Image-to-Video models)",type="filepath",visible=False)260 unmodified linesself.components["model_version"]],outputs=[self.components["conditioning_image"]])59 unmodified linesself.components["inference_steps"],self.components["enable_cpu_offload"],self.components["fps"],self.components["conditioning_image"],self.components["seed"],self.components["use_lora"]],8 unmodified lines"""Update UI based on the selected model version"""model_version_type = self.get_model_version_type(model_type, model_version)# Show conditioning image input only for image-to-video modelsshow_conditioning_image = model_version_type == "image-to-video"return {self.components["conditioning_image"]: gr.Image(visible=show_conditioning_image)}def sync_model_type_and_versions(self) -> Tuple[str, str]:144 unmodified linesinference_steps: int,enable_cpu_offload: bool,fps: int,conditioning_image: Optional[str] = None,seed: int = -1,use_lora: str = "Use LoRA model") -> Tuple[Optional[str], str, str]:61 unmodified linesinference_steps=inference_steps,enable_cpu_offload=enable_cpu_offload,fps=fps,conditioning_image=conditioning_image,seed=seed)102 unmodified lines103104105106107108109110111112113114115116117260 unmodified lines37837938038138238338438559 unmodified lines4454464474484494504514528 unmodified lines461462463464465466467468469470471472473474475476477478479480481482483484485486144 unmodified lines63163263363463563663763861 unmodified lines700701702703704705706707102 unmodified lines)# Add image input for image-to-video modelsself.components["first_frame_image"] = gr.Image(label="First Frame Image (for Image-to-Video models)",type="filepath",visible=False)# Add second image input for frame conditioning models (last frame)self.components["last_frame_image"] = gr.Image(label="Last Frame Image (for Frame conditioning models)",type="filepath",visible=False)260 unmodified linesself.components["model_version"]],outputs=[self.components["first_frame_image"],self.components["last_frame_image"]])59 unmodified linesself.components["inference_steps"],self.components["enable_cpu_offload"],self.components["fps"],self.components["first_frame_image"],self.components["last_frame_image"],self.components["seed"],self.components["use_lora"]],8 unmodified lines"""Update UI based on the selected model version"""model_version_type = self.get_model_version_type(model_type, model_version)# Show conditioning image input for image-to-video and frame-to-video modelsshow_conditioning_image = model_version_type in ["image-to-video", "frame-to-video"]# Show last frame image input only for frame-to-video modelsshow_last_frame_image = model_version_type == "frame-to-video"# Update labels based on model typeif model_version_type == "frame-to-video":first_frame_label = "First Frame Image (for Frame conditioning models)"last_frame_label = "Last Frame Image (for Frame conditioning models)"elif model_version_type == "image-to-video":first_frame_label = "Conditioning Image (for Image-to-Video models)"last_frame_label = "Last Frame Image (for Frame conditioning models)"else:first_frame_label = "Conditioning Image (for Image-to-Video models)"last_frame_label = "Last Frame Image (for Frame conditioning models)"return {self.components["first_frame_image"]: gr.Image(visible=show_conditioning_image, label=first_frame_label),self.components["last_frame_image"]: gr.Image(visible=show_last_frame_image, label=last_frame_label)}def sync_model_type_and_versions(self) -> Tuple[str, str]:144 unmodified linesinference_steps: int,enable_cpu_offload: bool,fps: int,first_frame_image: Optional[str] = None,last_frame_image: Optional[str] = None,seed: int = -1,use_lora: str = "Use LoRA model") -> Tuple[Optional[str], str, str]:61 unmodified linesinference_steps=inference_steps,enable_cpu_offload=enable_cpu_offload,fps=fps,first_frame_image=first_frame_image,last_frame_image=last_frame_image,seed=seed)
.claude/settings.local.jsonAdded+3
Dockerfile+1-1
degraded_finetrainers_requirements.txt+4-4
degraded_requirements.txt+1-1
docs/wan/README-for-Wan2.1-FLF2V-14B-720P-diffusers.mdAdded+246
docs/wan/README-for-Wan2.1-I2V-14B-480P-diffusers.mdAdded+310
docs/wan/README-for-Wan2.1-I2V-14B-720P-diffusers.mdAdded+311
requirements.txt+7-2
vms/config.py+5
vms/ui/project/services/previewing.py+79-34
vms/ui/project/tabs/preview_tab.py+35-9