Wan: Open and Advanced Large-Scale Video Generative Models
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
🔥 Latest News!!
Feb 25, 2025: 👋 We've released the inference code and weights of Wan2.1.
Feb 27, 2025: 👋 Wan2.1 has been integrated into ComfyUI. Enjoy!
📑 Todo List
Wan2.1 Text-to-Video
Multi-GPU Inference code of the 14B and 1.3B models
Checkpoints of the 14B and 1.3B models
Gradio demo
ComfyUI integration
Diffusers integration
Wan2.1 Image-to-Video
Assistant
User
erro: Step1: Init prompt_expander...2025-03-04 00:01:18.824233: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1741046479.098949 6612 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1741046479.175360 6612 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2025-03-04 00:01:19.761896: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Loading checkpoint shards: 100% 8/8 [00:04<00:00, 1.99it/s]
done
Step2: Init 14B t2v model...^C
To download a specific file from a Hugging Face model repository, you can use the huggingface_hub Python library or directly through a command like wget in Google Colab or another terminal environment.
Multi-GPU Inference code of the 14B model
Checkpoints of the 14B model
Gradio demo
ComfyUI integration
Diffusers integration
Quickstart
Installation
Clone the repo:
code
git clone https://github.com/Wan-Video/Wan2.1.git
cd Wan2.1
💡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.
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:
(1) Without Prompt Extension
To facilitate implementation, we will start with a basic version of the inference process that skips the prompt extension step.
Single-GPU inference
code
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."
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:
code
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."
💡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.
Multi-GPU inference using FSDP + xDiT USP
code
pip install "xfuser>=0.4.1"
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."
(2) Using Prompt Extension
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:
Use the Dashscope API for extension.
Apply for a dashscope.api_key in advance (EN | CN).
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.
Use the qwen-plus model for text-to-video tasks and qwen-vl-max for image-to-video tasks.
You can modify the model used for extension with the parameter --prompt_extend_model. For example:
code
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'
Using a local model for extension.
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.
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.
For image-to-video tasks, you can use models like Qwen/Qwen2.5-VL-7B-Instruct and Qwen/Qwen2.5-VL-3B-Instruct.
Larger models generally provide better extension results but require more GPU memory.
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:
code
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'
(3) Running local gradio
code
cd gradio
# if one uses dashscope’s API for prompt extension
DASH_API_KEY=your_key python t2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir ./Wan2.1-T2V-14B
# if one uses a local model for prompt extension
python t2v_14B_singleGPU.py --prompt_extend_method 'local_qwen' --ckpt_dir ./Wan2.1-T2V-14B
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:
(1) Without Prompt Extension
Single-GPU inference
code
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
code
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."
(2) Using Prompt Extension
The process of prompt extension can be referenced here.
Run with local prompt extension using Qwen/Qwen2.5-VL-7B-Instruct:
code
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 extension using dashscope:
code
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) Running local gradio
code
cd gradio
# if one only uses 480P model in gradio
DASH_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 gradio
DASH_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 gradio
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
Run Text-to-Image Generation
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:
Through manual evaluation, the results generated after prompt extension are superior to those from both closed-source and open-source models.
(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.
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).
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.
Community Contributions
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.
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.
(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.
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.
[image: figure1]
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.
[image: figure1]
Citation
If you find our work helpful, please cite us.
code
@article{wan2.1,
title = {Wan: Open and Advanced Large-Scale Video Generative Models},
author = {Wan Team},
journal = {},
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.
If you would like to leave a message to our research or product teams, feel free to join our Discord or WeChat groups!
To utilize Wan2.1 in Google Colab, you can create a Python notebook and use the following commands to set it up. Below is a structured guide to help you get Wan2.1 running in a Colab environment.
Make sure to adapt the commands in the cells as necessary depending on the specific configuration and requirements of your project:
Step 1: Set Up the Environment
Open a New Google Colab Notebook
Set Hardware Acceleration to GPU: Go to Runtime -> Change runtime type -> Select GPU.
Step 2: Clone the Repository and Install Dependencies
Now you can execute the generation script. Modify the --prompt as needed:
python
# Example running Text-to-Video generation
!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."
Step 5: Monitor Resource Usage
If you're using a model that may cause an OOM (Out-of-Memory) error, use the --offload_model parameter to reduce GPU usage:
python
!python generate.py \
--task t2v-1.3B \
--size 832*480 \
--ckpt_dir ./Wan2.1-T2V-1.3B \
--offload_model True \
--prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
Step 6: Run the Gradio Interface (Optional)
If you want to explore the models through a Gradio interface:
python
# Install Gradio if not already installed
!pip install gradio
# Run the Gradio app
!cd gradio && python t2v_14B_singleGPU.py --ckpt_dir ./Wan2.1-T2V-14B
Tips:
Model Selection: Choose the appropriate model based on your computational limitations and desired output resolution.
Dependencies: Ensure all required dependencies are installed as mentioned in the requirements.txt file.
Prompt Engineering: Experiment with different prompts to get varied results.
Conclusion
This setup should enable you to utilize the Wan2.1 video generation models in Google Colab effectively. Make sure to check the latest documentation of Wan2.1 for any updates or changes to the process.
The errors you are encountering in the Google Colab environment appear to be related to CUDA initialization and TensorFlow logging, which can occur due to various reasons, often related to the compatibility of versions or concurrent access to CUDA resources. Below are steps to troubleshoot and possibly resolve the issue:
Step-by-Step Troubleshooting
Restart the Runtime: Sometimes, these errors can be resolved by restarting the Colab runtime. This clears any cached processes that might be causing conflicts.
Go to Runtime -> Restart runtime.
Ensure Correct CUDA and TensorFlow Versions: Check that you are using a compatible version of TensorFlow and that the GPU is enabled in your notebook.
You can start by checking the installed version of TensorFlow and CUDA by running:
python
import tensorflow as tf
print("TensorFlow version:", tf.__version__)
Install Required Versions: If the TensorFlow version is not compatible, you might want to install a specified version. You can do so by running:
python
!pip install tensorflow==2.12.0 # specify the version that's compatible, adjust accordingly
Use a Clean Environment: If you continue to face issues, try installing dependencies after clearing the Colab environment.
python
# Clear any previous installations and install the required dependencies
!pip uninstall -y tensorflow tensorflow-gpu # adjust according to what's installed
!pip install -r requirements.txt
Reduce GPU Load: If you get out-of-memory errors (OOM) while initializing the model, use the --offload_model flag and any other parameters to fit into the GPU memory effectively.
Initialization Logging: You can suppress the warnings by setting the log level in TensorFlow before running the code for loading the model. Add this to your notebook:
python
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # Suppresses warnings
Check Your Code Structure: Ensure that the model initialization and generation calls are correctly structured and there are no syntax errors.
Code Example
Here’s a modified structure incorporating the above recommendations:
python
import os
import tensorflow as tf
# Suppress TensorFlow logging
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# Check TensorFlow version
print("TensorFlow version:", tf.__version__)
# Clone the repository and navigate to it
!git clone https://github.com/Wan-Video/Wan2.1.git
%cd Wan2.1
# Install required packages
!pip install -r requirements.txt
# Download the model (example: T2V-14B)
!huggingface-cli download Wan-AI/Wan2.1-T2V-14B --local-dir ./Wan2.1-T2V-14B
# Running the text-to-video generation
!python generate.py \
--task t2v-14B \
--size 1280*720 \
--ckpt_dir ./Wan2.1-T2V-14B \
--offload_model True \
--prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."
If the Issue Persists
Check Colab GPU: Ensure to verify that the Colab environment is set to use a GPU. Go to Runtime -> Change runtime type and select GPU.
Create a New Notebook: If the issue continues, you may want to start fresh with new notebook and go through the steps again to avoid any cached states.
If you've tried all the above suggestions and are still facing issues, the problem may be specific to the implementation in the library you're using, and checking the repository's open issues or documentation may provide further guidance.
Here’s how you can download the model file diffusion_pytorch_model-00001-of-00006.safetensors from the Hugging Face model repository using both methods:
Method 1: Using huggingface_hub
Install the huggingface_hub Library: First, ensure you have the huggingface_hub library installed. You can do this in your Colab notebook using:
python
!pip install huggingface_hub
Login to Hugging Face (Optional): If the model requires authentication (for private models), you can log in. If it's a public model, you can skip this step.
python
from huggingface_hub import login
login() # You'll be prompted to enter your Hugging Face token
Download the Model File: Now you can download the specific file using the following code snippet:
python
from huggingface_hub import hf_hub_download
# Specify the model repository and filename
model_id = "Wan-AI/Wan2.1-T2V-14B"
filename = "diffusion_pytorch_model-00001-of-00006.safetensors"
# Download the file
file_path = hf_hub_download(repo_id=model_id, filename=filename)
print("Downloaded file path:", file_path)
Method 2: Directly Using wget or curl
If you prefer to use a command-line tool like wget, you can also directly download the file by constructing the file download URL. Here’s how: