模型简介
模型特点
模型能力
使用案例
🚀 Wan2.1
Wan2.1是一套全面且开放的视频基础模型套件,突破了视频生成的边界。它具有卓越的性能,支持消费级GPU,能完成多种任务,还具备视觉文本生成能力和强大的视频VAE。
🚀 快速开始
安装
克隆仓库:
git clone https://github.com/Wan-Video/Wan2.1.git
cd Wan2.1
安装依赖:
# 确保torch >= 2.4.0
pip install -r requirements.txt
模型下载
模型 | 下载链接 | 说明 |
---|---|---|
T2V-14B | 🤗 Huggingface 🤖 ModelScope | 支持480P和720P |
I2V-14B-720P | 🤗 Huggingface 🤖 ModelScope | 支持720P |
I2V-14B-480P | 🤗 Huggingface 🤖 ModelScope | 支持480P |
T2V-1.3B | 🤗 Huggingface 🤖 ModelScope | 支持480P |
⚠️ 重要提示
1.3B模型能够生成720P分辨率的视频。然而,由于在该分辨率下的训练有限,与480P相比,结果通常不太稳定。为获得最佳性能,建议使用480P分辨率。
使用🤗 huggingface-cli下载模型:
pip install "huggingface_hub[cli]"
huggingface-cli download Wan-AI/Wan2.1-I2V-14B-480P --local-dir ./Wan2.1-I2V-14B-480P
使用🤖 modelscope-cli下载模型:
pip install modelscope
modelscope download Wan-AI/Wan2.1-I2V-14B-480P --local_dir ./Wan2.1-I2V-14B-480P
运行图像到视频生成
与文本到视频类似,图像到视频也分为有提示扩展步骤和无提示扩展步骤的过程。具体参数及其对应设置如下:
任务 | 480P分辨率 | 720P分辨率 | 模型 |
---|---|---|---|
i2v-14B | ❌ | ✔️ | Wan2.1-I2V-14B-720P |
i2v-14B | ✔️ | ❌ | Wan2.1-T2V-14B-480P |
(1)无提示扩展
- 单GPU推理
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."
💡 使用建议
对于图像到视频任务,
size
参数表示生成视频的区域,其宽高比遵循原始输入图像的宽高比。
- 使用FSDP + xDiT USP进行多GPU推理
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."
(2)使用提示扩展
使用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."
使用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)运行本地Gradio
cd gradio
# 如果只在Gradio中使用480P模型
DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P
# 如果只在Gradio中使用720P模型
DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P
# 如果在Gradio中同时使用480P和720P模型
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
✨ 主要特性
- 👍 SOTA性能:Wan2.1在多个基准测试中始终优于现有的开源模型和最先进的商业解决方案。
- 👍 支持消费级GPU:T2V - 1.3B模型仅需8.19 GB显存,几乎与所有消费级GPU兼容。它可以在RTX 4090上约4分钟内生成一个5秒的480P视频(不使用量化等优化技术),其性能甚至可与一些闭源模型相媲美。
- 👍 多任务支持:Wan2.1在文本到视频、图像到视频、视频编辑、文本到图像和视频到音频等任务中表现出色,推动了视频生成领域的发展。
- 👍 视觉文本生成:Wan2.1是首个能够同时生成中文和英文文本的视频模型,具有强大的文本生成能力,增强了其实用性。
- 👍 强大的视频VAE:Wan - VAE具有出色的效率和性能,能够对任意长度的1080P视频进行编码和解码,同时保留时间信息,非常适合视频生成任务。
📚 详细文档
人工评估
我们对图像到视频模型的性能进行了广泛的人工评估,结果如下所示。结果清楚地表明,Wan2.1优于闭源和开源模型。
不同GPU上的计算效率
我们在不同的GPU上测试了不同Wan2.1模型的计算效率,结果以总时间 (s) / 峰值GPU内存 (GB) 的格式呈现。
此表中测试的参数设置如下: (1)对于8个GPU上的1.3B模型,设置
--ring_size 8
和--ulysses_size 1
; (2)对于1个GPU上的14B模型,使用--offload_model True
; (3)对于单个4090 GPU上的1.3B模型,设置--offload_model True --t5_cpu
; (4)对于所有测试,均未应用提示扩展,即未启用--use_prompt_extend
。
Wan2.1介绍
Wan2.1基于主流的扩散变压器范式设计,通过一系列创新在生成能力方面取得了显著进展。这些创新包括新颖的时空变分自编码器(VAE)、可扩展的训练策略、大规模数据构建和自动化评估指标。这些贡献共同提升了模型的性能和通用性。
(1)3D变分自编码器
我们提出了一种新颖的3D因果VAE架构,称为Wan - VAE,专门用于视频生成。通过结合多种策略,我们提高了时空压缩率,减少了内存使用,并确保了时间因果性。与其他开源VAE相比,Wan - VAE在性能效率方面具有显著优势。此外,我们的Wan - VAE可以对无限长度的1080P视频进行编码和解码,而不会丢失历史时间信息,特别适合视频生成任务。
(2)视频扩散DiT
Wan2.1在主流扩散变压器范式内使用流匹配框架进行设计。我们的模型架构使用T5编码器对多语言文本输入进行编码,每个变压器块中的交叉注意力将文本嵌入到模型结构中。此外,我们使用一个带有线性层和SiLU层的MLP来处理输入时间嵌入,并分别预测六个调制参数。这个MLP在所有变压器块中共享,每个块学习一组不同的偏差。我们的实验结果表明,在相同的参数规模下,这种方法显著提高了性能。
模型 | 维度 | 输入维度 | 输出维度 | 前馈维度 | 频率维度 | 头数 | 层数 |
---|---|---|---|---|---|---|---|
1.3B | 1536 | 16 | 16 | 8960 | 256 | 12 | 30 |
14B | 5120 | 16 | 16 | 13824 | 256 | 40 | 40 |
数据
我们策划并去重了一个包含大量图像和视频数据的候选数据集。在数据策划过程中,我们设计了一个四步的数据清理过程,重点关注基本维度、视觉质量和运动质量。通过强大的数据处理管道,我们可以轻松获得高质量、多样化和大规模的图像和视频训练集。
与SOTA模型的比较
我们将Wan2.1与领先的开源和闭源模型进行了比较,以评估其性能。使用我们精心设计的1035个内部提示集,我们在14个主要维度和26个子维度上进行了测试。然后,我们通过对每个维度的分数进行加权计算得出总分,权重来自匹配过程中的人类偏好。详细结果如下所示,这些结果表明我们的模型优于开源和闭源模型。
📄 许可证
本仓库中的模型遵循Apache 2.0许可证。我们对您生成的内容不主张任何权利,允许您自由使用这些内容,但您的使用必须符合本许可证的规定。您应对模型的使用负全部责任,不得使用模型分享任何违反适用法律、伤害个人或群体、传播用于伤害的个人信息、传播错误信息或针对弱势群体的内容。有关完整的限制列表和您的权利详情,请参阅许可证全文。
致谢
我们感谢SD3、Qwen、umt5 - xxl、diffusers和HuggingFace仓库的贡献者们的开放研究。
联系我们





