Wan2.1:基于视频生成技术的开源基础模型套件项目

用户可利用该项目进行文本转视频、图像转视频、视频编辑等多任务创作。它具备SOTA性能,支持消费级GPU运行,能生成中英文视觉文本,还拥有高效的视频VAE,推动视频生成领域发展。【此简介由AI生成】

Branch2Tags0
FilesLast commitLast update
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
1 year ago
1 year ago
1 year ago

Wan2.1

💜 Wan    |    🖥️ GitHub    |   🤗 Hugging Face   |   🤖 ModelScope   |    📑 技术报告    |    📑 博客    |   💬 微信群   |    📖 Discord  


Wan: Open and Advanced Large-Scale Video Generative Models

本仓库中,我们推出Wan2.1——一套全面开放的视频基础模型套件,旨在突破视频生成领域的技术边界。Wan2.1具备以下核心特性:

  • 👍 顶尖性能:在多项基准测试中,Wan2.1持续超越现有开源模型及业界领先的商业解决方案。
  • 👍 支持消费级GPU:T2V-1.3B模型仅需8.19 GB显存,几乎适配所有消费级GPU。在RTX 4090上,生成5秒480P视频耗时约4分钟(未采用量化等优化技术),性能甚至可媲美部分闭源模型。
  • 👍 多任务支持:Wan2.1在文本生成视频(Text-to-Video)、图像生成视频(Image-to-Video)、视频编辑(Video Editing)、文本生成图像(Text-to-Image)及视频生成音频(Video-to-Audio)等任务上表现卓越,推动视频生成领域的全面发展。
  • 👍 视觉文本生成:Wan2.1是首个支持中英文文本生成的视频模型,文本生成效果稳定可靠,显著提升了模型的实际应用价值。
  • 👍 高效视频VAE:Wan-VAE兼顾高效性与高性能,可对任意长度的1080P视频进行编解码,同时完整保留时序信息,为视频及图像生成任务提供理想基础。

视频演示

🔥 最新动态!!

  • 2025年5月14日:👋 我们正式推出 Wan2.1 VACE——一款集视频创作与编辑于一体的全能模型,同步开放其推理代码、模型权重及技术报告!
  • 2025年4月17日:👋 我们发布 Wan2.1 FLF2V,并提供推理代码与模型权重!
  • 2025年3月21日:👋 我们荣幸宣布 Wan2.1 技术报告正式发布,欢迎大家参与讨论并提出宝贵反馈!
  • 2025年3月3日:👋 Wan2.1 的文本生成视频(T2V)和图像生成视频(I2V)功能已集成至 Diffusers 库(T2V | I2V),欢迎体验!
  • 2025年2月27日:👋 Wan2.1 已集成至 ComfyUI,尽情探索吧!
  • 2025年2月25日:👋 我们已开放 Wan2.1 的推理代码与模型权重。

社区成果

如果您的工作对 Wan2.1 进行了改进,并希望更多人了解,欢迎与我们联系。

  • Helios:基于 Wan2.1 开发的突破性视频生成模型,在单张 H100 GPU 上可实现分钟级高质量视频合成,帧率达 19.5 FPS(在单张昇腾 NPU 上约为 10 FPS)——无需依赖传统长视频防漂移策略或标准视频加速技术。更多详情请访问其网页。
  • Video-As-Prompt:首个基于 Wan2.1-14B-I2V 的语义可控视频生成统一模型,采用混合Transformer架构,支持上下文控制(如概念、风格、运动、镜头)。更多示例请参考项目页面。
  • LightX2V:轻量级高效视频生成框架,集成 Wan2.1 与 Wan2.2,支持多种工程加速技术以实现快速推理,可在 RTX 5090 和 RTX 4060(8GB 显存)上运行。
  • DriVerse:基于 Wan2.1-14B-I2V 的自动驾驶世界模型,可根据任意场景帧和给定轨迹生成未来驾驶视频。更多示例请参考项目页面。
  • Training-Free-WAN-Editing:构建于 Wan2.1-T2V-1.3B,支持基于图像的无训练编辑方法(如 FlowEdit 和 FlowAlign)进行无训练视频编辑。
  • Wan-Move:已被 NeurIPS 2025 接收,该框架将 Wan2.1-I2V-14B 提升至细粒度点级运动控制的 SOTA 水平!更多信息请参考项目页面。
  • EchoShot:基于 Wan2.1-T2V-1.3B 的原生多镜头人像视频生成模型,可生成包含同一角色的多个视频片段,并具备高度灵活的内容可控性。更多信息请参考项目页面。
  • AniCrafter:基于 Wan2.1-14B-I2V 的以人为中心的动画模型,通过 3DGS 虚拟化身控制视频扩散模型,可将任何人插入任意场景并按照给定运动序列进行动画制作。更多示例请参考项目页面。
  • HyperMotion:基于 Wan2.1 的人体图像动画框架,解决了姿态引导动画中复杂人体运动生成的难题。更多示例请参考网站。
  • MagicTryOn:基于 Wan2.1-14B-I2V 构建的视频虚拟试衣框架,解决了现有模型在服装细节表达和人体运动动态稳定性方面的局限性。更多示例请参考网站。
  • ATI:构建于 Wan2.1-I2V-14B,是一种基于轨迹的运动控制框架,可统一视频生成中的物体运动、局部运动和相机运动。更多示例请参考网站。
  • Phantom:基于 Wan2.1-T2V-1.3B 和 Wan2.1-T2V-14B 开发了单主体和多主体参考的统一视频生成框架。更多示例请参考项目。
  • UniAnimate-DiT:基于 Wan2.1-14B-I2V 训练的人体图像动画模型,并开源了推理和训练代码,欢迎体验!
  • CFG-Zero:从 CFG 角度对 Wan2.1(涵盖 T2V 和 I2V 模型)进行增强。
  • TeaCache:现已支持 Wan2.1 加速,可提升约 2 倍速度,欢迎尝试!
  • DiffSynth-Studio:为 Wan2.1 提供更多支持,包括视频转视频、FP8 量化、显存优化、LoRA 训练等。更多示例请参考项目。

📑 任务清单

  • Wan2.1 文本转视频
  • Wan2.1 图像转视频
  • Wan2.1 首末帧转视频
  • Wan2.1 VACE

快速开始

安装

克隆仓库:

git clone https://github.com/Wan-Video/Wan2.1.git
cd Wan2.1

安装依赖项:

# Ensure 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
FLF2V-14B 🤗 Huggingface 🤖 ModelScope 支持720P
VACE-1.3B 🤗 Huggingface 🤖 ModelScope 支持480P
VACE-14B 🤗 Huggingface 🤖 ModelScope 支持480P和720P

💡注意:

  • 1.3B模型能够生成720P分辨率的视频。但由于该分辨率下的训练数据有限,生成结果通常不如480P稳定。为获得最佳效果,建议使用480P分辨率。
  • 对于首末帧转视频生成任务,我们的模型主要基于中文文本-视频对进行训练。因此,建议使用中文提示词以获得更好的结果。

使用huggingface-cli下载模型:

pip install "huggingface_hub[cli]"
huggingface-cli download Wan-AI/Wan2.1-T2V-14B --local-dir ./Wan2.1-T2V-14B

使用 modelscope-cli 下载模型:

pip install modelscope
modelscope download Wan-AI/Wan2.1-T2V-14B --local_dir ./Wan2.1-T2V-14B

运行文本转视频生成

本仓库支持两种文本转视频模型(1.3B 和 14B)以及两种分辨率(480P 和 720P)。这些模型的参数和配置如下:

任务 分辨率 模型
480P 720P
t2v-14B ✔️ ✔️ Wan2.1-T2V-14B
t2v-1.3B ✔️ ❌ Wan2.1-T2V-1.3B
(1)不使用提示词扩展

为方便实施,我们将从推理过程的基础版本开始,该版本将跳过提示词扩展步骤。

  • 单 GPU 推理
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."

如果遇到 OOM(内存不足)问题,可以使用 --offload_model True 和 --t5_cpu 选项来减少 GPU 内存占用。例如,在 RTX 4090 GPU 上:

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."

💡注意:如果您使用的是 T2V-1.3B 模型,建议将参数 --sample_guide_scale 设置为 6。--sample_shift 参数可根据性能在 8 到 12 的范围内进行调整。

  • 使用 FSDP + xDiT USP 进行多 GPU 推理

    我们使用 FSDP 和 xDiT USP 来加速推理。

    • Ulysess 策略

      如果您想使用 Ulysses 策略,应设置 --ulysses_size $GPU_NUMS。请注意,如果您希望使用 Ulysess 策略,num_heads 应能被 ulysses_size 整除。对于 1.3B 模型,num_heads 为 12,无法被 8 整除(因为大多数多 GPU 机器配备 8 块 GPU)。因此,建议改用 Ring 策略。

    • Ring 策略

      如果您想使用 Ring 策略,应设置 --ring_size $GPU_NUMS。请注意,使用 Ring 策略时,sequence length 应能被 ring_size 整除。

    当然,您也可以组合使用 Ulysses 和 Ring 策略。

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) 使用提示词扩展

扩展提示词能够有效丰富生成视频中的细节,进一步提升视频质量。因此,我们建议启用提示词扩展功能。我们提供以下两种提示词扩展方法:

  • 使用Dashscope API进行扩展。
    • 提前申请dashscope.api_key(英文 | 中文)。
    • 配置环境变量DASH_API_KEY以指定Dashscope API密钥。对于阿里云国际站用户,还需将环境变量DASH_API_URL设置为'https://dashscope-intl.aliyuncs.com/api/v1'。更详细的说明,请参考dashscope文档。
    • 文本转视频任务使用qwen-plus模型,图像转视频任务使用qwen-vl-max模型。
    • 您可以通过参数--prompt_extend_model修改用于扩展的模型。例如:
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'
  • 使用本地模型进行扩展。

    • 本扩展默认使用 HuggingFace 上的 Qwen 模型。用户可根据可用 GPU 内存大小选择 Qwen 模型或其他模型。
    • 对于文本转视频任务,可使用 Qwen/Qwen2.5-14B-Instruct、Qwen/Qwen2.5-7B-Instruct 和 Qwen/Qwen2.5-3B-Instruct 等模型。
    • 对于图像转视频或首末帧转视频任务,可使用 Qwen/Qwen2.5-VL-7B-Instruct 和 Qwen/Qwen2.5-VL-3B-Instruct 等模型。
    • 通常情况下,模型越大,扩展效果越好,但所需 GPU 内存也越多。
    • 您可以通过参数 --prompt_extend_model 修改用于扩展的模型,该参数允许您指定本地模型路径或 Hugging Face 模型。例如:
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) 使用 Diffusers 运行

您可以通过以下命令使用 Diffusers 轻松对 Wan2.1-T2V 进行推理:

import torch
from diffusers.utils import export_to_video
from diffusers import AutoencoderKLWan, WanPipeline
from diffusers.schedulers.scheduling_unipc_multistep import UniPCMultistepScheduler

# Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers
model_id = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
flow_shift = 5.0 # 5.0 for 720P, 3.0 for 480P
scheduler = UniPCMultistepScheduler(prediction_type='flow_prediction', use_flow_sigmas=True, num_train_timesteps=1000, flow_shift=flow_shift)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
pipe.scheduler = scheduler
pipe.to("cuda")

prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
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(
     prompt=prompt,
     negative_prompt=negative_prompt,
     height=720,
     width=1280,
     num_frames=81,
     guidance_scale=5.0,
    ).frames[0]
export_to_video(output, "output.mp4", fps=16)

💡注意:请注意,此示例未集成 Prompt Extension 和分布式推理。我们将很快更新集成了 prompt 扩展和多 GPU 版本的 Diffusers。

(4) 运行本地 gradio
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

运行图像转视频生成

与文本转视频类似,图像转视频也分为带提示词扩展步骤和不带提示词扩展步骤的流程。具体参数及对应设置如下:

任务 分辨率 模型
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 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."

💡对于图像转视频任务,size参数表示生成视频的面积,其宽高比将遵循原始输入图像的宽高比。

  • 采用FSDP + xDiT USP的多GPU推理
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) 使用提示词扩展

提示词扩展的流程可参考此处。

使用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."

使用 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) 使用 Diffusers 运行

您可以使用以下命令通过 Diffusers 轻松对 Wan2.1-I2V 进行推理:

import torch
import numpy as np
from diffusers import AutoencoderKLWan, WanImageToVideoPipeline
from diffusers.utils import export_to_video, load_image
from transformers import CLIPVisionModel

# Available models: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers, Wan-AI/Wan2.1-I2V-14B-720P-Diffusers
model_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 * 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))
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)

💡注意:请注意,本示例未集成 Prompt Extension 和分布式推理。我们将很快更新集成了 prompt 扩展和多 GPU 版本的 Diffusers。

(4) 运行本地 gradio
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

运行首末帧转视频生成

首末帧转视频同样分为带提示词扩展步骤和不带提示词扩展步骤的流程。目前仅支持720P。具体参数及对应设置如下:

任务 分辨率 模型
480P 720P
flf2v-14B ❌ ✔️ Wan2.1-FLF2V-14B-720P
(1) 不带提示词扩展
  • 单GPU推理
python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --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."

💡与Image-to-Video类似,size参数表示生成视频的面积,其宽高比遵循原始输入图像的宽高比。

  • 采用FSDP + xDiT USP的多GPU推理
pip install "xfuser>=0.4.1"
torchrun --nproc_per_node=8 generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --dit_fsdp --t5_fsdp --ulysses_size 8 --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."
(2) 使用提示词扩展

提示词扩展的流程可参考此处。

使用Qwen/Qwen2.5-VL-7B-Instruct运行本地提示词扩展:

python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --use_prompt_extend --prompt_extend_model Qwen/Qwen2.5-VL-7B-Instruct --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."

使用 dashscope 通过远程提示扩展运行:

DASH_API_KEY=your_key python generate.py --task flf2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-FLF2V-14B-720P --first_frame examples/flf2v_input_first_frame.png --last_frame examples/flf2v_input_last_frame.png --use_prompt_extend --prompt_extend_method 'dashscope' --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."
(3) 运行本地 gradio
cd gradio
# use 720P model in gradio
DASH_API_KEY=your_key python flf2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-FLF2V-14B-720P

运行VACE

VACE 目前支持两种模型(1.3B和14B)以及两种主要分辨率(480P和720P)。 输入支持任意分辨率,但为达到最佳效果,视频尺寸应处于特定范围内。 这些模型的参数和配置如下:

任务 分辨率 模型
480P(~81x480x832) 720P(~81x720x1280)
VACE ✔️ ✔️ Wan2.1-VACE-14B
VACE ✔️ ❌ Wan2.1-VACE-1.3B

在VACE中,用户可以输入文本提示以及可选的视频、遮罩和图像,以进行视频生成或编辑。VACE的详细使用说明可参见用户指南。 执行流程如下:

(1) 预处理

用户收集的素材需要预处理为VACE可识别的输入,包括src_video、src_mask、src_ref_images和prompt。 对于R2V(参考图转视频生成),可跳过此预处理步骤;但对于V2V(视频转视频编辑)和MV2V(遮罩视频转视频编辑)任务,则需要额外的预处理来获取包含深度、姿态或遮罩区域等条件的视频。 更多详情,请参考vace_preproccess。

(2) 命令行推理
  • 单GPU推理
python generate.py --task vace-1.3B --size 832*480 --ckpt_dir ./Wan2.1-VACE-1.3B --src_ref_images examples/girl.png,examples/snake.png --prompt "在一个欢乐而充满节日气氛的场景中,穿着鲜艳红色春服的小女孩正与她的可爱卡通蛇嬉戏。她的春服上绣着金色吉祥图案,散发着喜庆的气息,脸上洋溢着灿烂的笑容。蛇身呈现出亮眼的绿色,形状圆润,宽大的眼睛让它显得既友善又幽默。小女孩欢快地用手轻轻抚摸着蛇的头部,共同享受着这温馨的时刻。周围五彩斑斓的灯笼和彩带装饰着环境,阳光透过洒在她们身上,营造出一个充满友爱与幸福的新年氛围。"
  • 采用 FSDP + xDiT USP 的多 GPU 推理
torchrun --nproc_per_node=8 generate.py --task vace-14B --size 1280*720 --ckpt_dir ./Wan2.1-VACE-14B --dit_fsdp --t5_fsdp --ulysses_size 8 --src_ref_images examples/girl.png,examples/snake.png --prompt "在一个欢乐而充满节日气氛的场景中,穿着鲜艳红色春服的小女孩正与她的可爱卡通蛇嬉戏。她的春服上绣着金色吉祥图案,散发着喜庆的气息,脸上洋溢着灿烂的笑容。蛇身呈现出亮眼的绿色,形状圆润,宽大的眼睛让它显得既友善又幽默。小女孩欢快地用手轻轻抚摸着蛇的头部,共同享受着这温馨的时刻。周围五彩斑斓的灯笼和彩带装饰着环境,阳光透过洒在她们身上,营造出一个充满友爱与幸福的新年氛围。"
(3) 运行本地 gradio
  • 单 GPU 推理
python gradio/vace.py --ckpt_dir ./Wan2.1-VACE-1.3B
  • 采用 FSDP + xDiT USP 的多 GPU 推理
python gradio/vace.py --mp --ulysses_size 8 --ckpt_dir ./Wan2.1-VACE-14B/

运行文本到图像生成

Wan2.1 是一个集图像和视频生成为一体的统一模型。由于它同时在这两类数据上进行了训练,因此也能够生成图像。生成图像的命令与视频生成类似,具体如下:

(1)不使用提示词扩展
  • 单 GPU 推理
python generate.py --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B  --prompt '一个朴素端庄的美人'
  • 基于 FSDP + xDiT USP 的多 GPU 推理
torchrun --nproc_per_node=8 generate.py --dit_fsdp --t5_fsdp --ulysses_size 8 --base_seed 0 --frame_num 1 --task t2i-14B  --size 1024*1024 --prompt '一个朴素端庄的美人' --ckpt_dir ./Wan2.1-T2V-14B
(2) 采用提示词扩展
  • 单GPU推理
python generate.py --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B  --prompt '一个朴素端庄的美人' --use_prompt_extend
  • 使用 FSDP + xDiT USP 进行多 GPU 推理
torchrun --nproc_per_node=8 generate.py --dit_fsdp --t5_fsdp --ulysses_size 8 --base_seed 0 --frame_num 1 --task t2i-14B  --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B --prompt '一个朴素端庄的美人' --use_prompt_extend

人工评估

(1)文本到视频评估

经过人工评估,提示词扩展后生成的结果优于闭源模型和开源模型的输出。

(2)图像到视频评估

我们同样进行了大量人工评估以测试图像到视频模型的性能,结果如下表所示。结果清晰表明,Wan2.1 在性能上超越了闭源和开源模型。

不同GPU上的计算效率

我们在下表中测试了不同 Wan2.1 模型在不同GPU上的计算效率。结果以 总时间(秒)/ 峰值GPU内存(GB) 的格式呈现。

本表格中测试的参数设置如下: (1)对于8块GPU上的1.3B模型,设置 --ring_size 8 和 --ulysses_size 1; (2)对于单块GPU上的14B模型,使用 --offload_model True; (3)对于单块4090 GPU上的1.3B模型,设置 --offload_model True --t5_cpu; (4)所有测试均未应用提示词扩展,即未启用 --use_prompt_extend。

💡注意:T2V-14B 比 I2V-14B 速度慢,原因是前者采样50步,而后者使用40步。


Wan2.1介绍

Wan2.1 基于主流的扩散Transformer范式设计,通过一系列创新实现了生成能力的显著提升。这些创新包括我们提出的新型时空变分自编码器(VAE)、可扩展训练策略、大规模数据构建以及自动化评估指标。这些贡献共同增强了模型的性能和通用性。

(1)3D变分自编码器

我们提出了一种新型3D因果VAE架构,称为 Wan-VAE,专门为视频生成设计。通过结合多种策略,我们改进了时空压缩效果,降低了内存占用,并确保了时间因果性。与其他开源VAE相比,Wan-VAE 在性能效率方面表现出显著优势。此外,我们的 Wan-VAE 能够对无限长度的1080P视频进行编码和解码,且不会丢失历史时间信息,使其特别适用于视频生成任务。

(2)视频扩散DiT

Wan2.1 在主流扩散Transformer范式下采用流匹配(Flow Matching)框架设计。我们模型的架构使用T5编码器对多语言文本输入进行编码,每个Transformer块中的交叉注意力将文本嵌入到模型结构中。此外,我们采用包含一个线性层和一个SiLU层的MLP来处理输入的时间嵌入,并分别预测六个调制参数。该MLP在所有Transformer块之间共享,每个块学习一组独特的偏置。我们的实验结果表明,在相同参数规模下,这种方法能带来显著的性能提升。

模型 维度 输入维度 输出维度 前馈维度 频率维度 头数 层数
1.3B 1536 16 16 8960 256 12 30
14B 5120 16 16 13824 256 40 40
数据

我们精心筛选并去重了包含海量图像和视频数据的候选数据集。在数据筛选过程中,我们设计了四步数据清洗流程,重点关注基础维度、视觉质量和运动质量。通过这个稳健的数据处理管道,我们能够轻松获取高质量、多样化且大规模的图像和视频训练集。

figure1

与SOTA的对比

我们将 Wan2.1 与领先的开源和闭源模型进行了性能对比。使用我们精心设计的1035条内部提示词,我们在14个主要维度和26个子维度上进行了测试。然后,我们通过对每个维度的得分进行加权计算来得出总分,权重来源于人工偏好匹配过程。详细结果如下表所示。这些结果表明,我们的模型在性能上优于开源和闭源模型。

figure1

引用说明

如果您觉得我们的研究工作对您有所帮助,请引用我们的成果。

@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 仓库的贡献者们,感谢他们的开放研究。

联系我们

如果您想给我们的研究或产品团队留言,欢迎加入我们的 Discord 或 微信群!

Introduction

用户可利用该项目进行文本转视频、图像转视频、视频编辑等多任务创作。它具备SOTA性能,支持消费级GPU运行,能生成中英文视觉文本,还拥有高效的视频VAE,推动视频生成领域发展。【此简介由AI生成】

Customize your domain