💜 Wan | 🖥️ GitHub | 🤗 Hugging Face | 🤖 ModelScope | 📑 技术报告 | 📑 博客 | 💬 微信群 | 📖 Discord
Wan: Open and Advanced Large-Scale Video Generative Models
我们荣幸地推出Wan2.2,这是我们基础视频模型的重大升级版本。在Wan2.2的研发中,我们重点融入了以下创新技术:
👍 高效的MoE架构:Wan2.2在视频扩散模型中引入了混合专家(Mixture-of-Experts, MoE)架构。通过使用专门的强大专家模型分离跨时间步的去噪过程,在保持相同计算成本的同时,显著提升了整体模型容量。
👍 电影级美学表现:Wan2.2整合了精心筛选的美学数据,并附有详细的光照、构图、对比度、色调等标签。这使得电影风格生成更加精准可控,便于创建符合个性化审美偏好的视频内容。
👍 复杂动作生成能力:与Wan2.1相比,Wan2.2的训练数据规模大幅扩展,图像数据增加65.6%,视频数据增加83.2%。这种扩展显著增强了模型在动作、语义和美学等多个维度的泛化能力,在所有开源和闭源模型中均达到顶尖性能。
👍 高效高清混合TI2V:Wan2.2开源了基于先进Wan2.2-VAE构建的5B模型,该VAE实现了16×16×4的压缩比。此模型支持720P分辨率、24fps的文本生成视频(text-to-video)和图像生成视频(image-to-video)任务,且可在消费级显卡(如4090)上运行。它是目前速度最快的720P@24fps模型之一,能够同时服务于工业界和学术界。
本仓库还包含我们专为图像生成视频任务设计的I2V-A14B模型,支持480P和720P两种分辨率。该模型采用混合专家(MoE)架构,实现了更稳定的视频合成效果,减少了不自然的镜头运动,并增强了对多样化风格场景的支持。
如果您的研究或项目基于 Wan2.1 或 Wan2.2 构建,欢迎与我们分享,以便我们向更广泛的社区展示。
克隆本仓库:
git clone https://github.com/Wan-Video/Wan2.2.git
cd Wan2.2安装依赖项:
# Ensure torch >= 2.4.0
# If the installation of `flash_attn` fails, try installing the other packages first and install `flash_attn` last
pip install -r requirements.txt| 模型名称 | 下载链接 | 描述信息 |
|---|---|---|
| T2V-A14B | 🤗 Huggingface 🤖 ModelScope | 文本转视频MoE模型,支持480P及720P |
| I2V-A14B | 🤗 Huggingface 🤖 ModelScope | 图像转视频MoE模型,支持480P及720P |
| TI2V-5B | 🤗 Huggingface 🤖 ModelScope | 高压缩VAE,集成文本转视频与图像转视频功能,支持720P |
💡注意: TI2V-5B模型支持以24 FPS生成720P视频。
使用huggingface-cli下载模型:
pip install "huggingface_hub[cli]"
huggingface-cli download Wan-AI/Wan2.2-I2V-A14B --local-dir ./Wan2.2-I2V-A14B使用 modelscope-cli 下载模型:
pip install modelscope
modelscope download Wan-AI/Wan2.2-I2V-A14B --local_dir ./Wan2.2-I2V-A14B本仓库支持Wan2.2-I2V-A14B图像转视频模型,并可同时支持480P和720P分辨率的视频生成。
python generate.py --task i2v-A14B --size 1280*720 --ckpt_dir ./Wan2.2-I2V-A14B --offload_model True --convert_model_dtype --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."此命令可在至少拥有 80GB VRAM 的 GPU 上运行。
💡在图像转视频任务中,
size参数代表生成视频的面积,其宽高比将遵循原始输入图像的宽高比。
torchrun --nproc_per_node=8 generate.py --task i2v-A14B --size 1280*720 --ckpt_dir ./Wan2.2-I2V-A14B --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."DASH_API_KEY=your_key torchrun --nproc_per_node=8 generate.py --task i2v-A14B --size 1280*720 --ckpt_dir ./Wan2.2-I2V-A14B --prompt '' --image examples/i2v_input.JPG --dit_fsdp --t5_fsdp --ulysses_size 8 --use_prompt_extend --prompt_extend_method 'dashscope'💡该模型仅通过输入图像即可生成视频。您可以使用提示词扩展功能从图像生成提示词。
提示词扩展的操作流程可参考此处。
import torch
import numpy as np
from diffusers import WanImageToVideoPipeline
from diffusers.utils import export_to_video, load_image
model_id = "Wan-AI/Wan2.2-I2V-A14B-Diffusers"
dtype = torch.bfloat16
device = "cuda"
pipe = WanImageToVideoPipeline.from_pretrained(model_id, torch_dtype=dtype)
pipe.to(device)
image = load_image(
"https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
)
max_area = 480 * 832
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))
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."
negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
generator = torch.Generator(device=device).manual_seed(0)
output = pipe(
image=image,
prompt=prompt,
negative_prompt=negative_prompt,
height=height,
width=width,
num_frames=81,
guidance_scale=3.5,
num_inference_steps=40,
generator=generator,
).frames[0]
export_to_video(output, "i2v_output.mp4", fps=16)💡注意:此模型需要当前仅在 diffusers 主分支中提供的功能。PyPI 上的最新稳定版本尚未包含这些更新。 要使用此模型,请从源代码安装库:
pip install git+https://github.com/huggingface/diffusers
我们在下表中测试了不同 Wan2.2 模型在不同 GPU 上的计算效率。结果以 总时间(秒)/ 峰值 GPU 内存(GB) 的格式呈现。
本表格所示测试的参数设置如下: (1)多 GPU:14B:
--ulysses_size 4/8 --dit_fsdp --t5_fsdp,5B:--ulysses_size 4/8 --offload_model True --convert_model_dtype --t5_cpu;单 GPU:14B:--offload_model True --convert_model_dtype,5B:--offload_model True --convert_model_dtype --t5_cpu(--convert_model_dtype 将模型参数类型转换为 config.param_dtype); (2)分布式测试利用内置的 FSDP 和 Ulysses 实现,并在 Hopper 架构 GPU 上部署了 FlashAttention3; (3)测试运行时未使用--use_prompt_extend标志; (4)报告的结果是预热阶段后采集的多个样本的平均值。
Wan2.2 在 Wan2.1 的基础上,在生成质量和模型能力方面有显著提升。此次升级由一系列关键技术创新推动,主要包括混合专家(Mixture-of-Experts,MoE)架构、升级的训练数据以及高压缩视频生成。
Wan2.2 将混合专家(Mixture-of-Experts,MoE)架构引入视频生成扩散模型。MoE 在大型语言模型中已被广泛验证是一种在几乎不增加推理成本的情况下有效增加模型总参数量的方法。在 Wan2.2 中,A14B 模型系列采用了针对扩散模型去噪过程定制的双专家设计:一个高噪声专家用于早期阶段,专注于整体布局;一个低噪声专家用于后期阶段,精细化视频细节。每个专家模型拥有约 14B 参数,因此总参数量达到 27B,但每一步仅激活 14B 参数,使得推理计算量和 GPU 内存占用几乎保持不变。
两个专家之间的切换点由信噪比(SNR)决定,该指标随去噪步骤 的增加而单调降低。在去噪过程开始时, 较大且噪声水平较高,因此 SNR 处于最小值,记为 。在此阶段,高噪声专家被激活。我们定义一个对应于 一半的阈值步骤 ,当 时切换到低噪声专家。
为验证 MoE 架构的有效性,我们基于验证损失曲线比较了四种设置。基线 Wan2.1 模型未采用 MoE 架构。在基于 MoE 的变体中,Wan2.1 & High-Noise Expert 重用 Wan2.1 模型作为低噪声专家,同时使用 Wan2.2 的高噪声专家;Wan2.1 & Low-Noise Expert 则使用 Wan2.1 作为高噪声专家,并采用 Wan2.2 的低噪声专家。Wan2.2 (MoE)(我们的最终版本)实现了最低的验证损失,表明其生成的视频分布最接近真实数据,并且收敛性更优。
为实现更高效的部署,Wan2.2 还探索了高压缩设计。除了 27B 的 MoE 模型外,我们还发布了一个 5B 的密集模型,即 TI2V-5B。它由高压缩的 Wan2.2-VAE 提供支持,该 VAE 实现了 为 的压缩比,将整体压缩率提高到 64,同时保持高质量的视频重建。通过额外的分块层(patchification layer),TI2V-5B 的总压缩比达到 。在没有特定优化的情况下,TI2V-5B 可以在单消费级 GPU 上用不到 9 分钟的时间生成 5 秒的 720P 视频,跻身最快的 720P@24fps 视频生成模型行列。该模型还在单一统一框架中原生支持文本到视频和图像到视频任务,覆盖学术研究和实际应用场景。
我们在新的 Wan-Bench 2.0 上将 Wan2.2 与领先的闭源商业模型进行了比较,从多个关键维度评估性能。结果表明,Wan2.2 实现了优于这些领先模型的性能。
如果您发现我们的工作对您有所帮助,请引用我们。
@article{wan2025,
title={Wan: Open and Advanced Large-Scale Video Generative Models},
author={Team Wan 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}
}本仓库中的模型采用 Apache 2.0 许可协议授权。对于您生成的内容,我们不主张任何权利,您可自由使用这些内容,但需确保您的使用符合本许可协议的规定。您对模型的使用行为负全部责任,不得分享任何违反适用法律、对个人或群体造成伤害、传播用于伤害目的的个人信息、散布错误信息或针对弱势群体的内容。有关权利的完整限制和详细说明,请参阅许可协议全文。
感谢 SD3、Qwen、umt5-xxl、diffusers 和 HuggingFace 仓库的贡献者们所做的开源研究工作。