Ascend-SACT/Wan
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

概述

通义万相 Wan2.2,系阿里于2025年7月28日开源的视频生成模型。通义万相2.2在视频生成扩散模型中引入MoE架构,解决了视频生成处理Token过长导致的计算资源消耗大问题。2025年7月28日,阿里开源视频生成模型:通义万相 Wan2.2。 通义万相2.2在视频生成扩散模型中引入MoE架构,解决了视频生成处理Token过长导致的计算资源消耗大问题。Wan2.2-T2V-A14B、Wan2.2-I2V-A14B两款模型均由高噪声专家模型和低噪专家模型组成,分别负责视频的整体布局和细节完善,在同参数规模下,可节省约50%的计算资源消耗,在模型能力上,通义万相2.2在复杂运动生成、人物交互、美学表达、复杂运动等维度上也取得了显著提升。 Wan2.2首创「电影美学控制系统」,光影、色彩、构图、微表情等能力媲美专业电影水平。例如,用户输入「黄昏」、「柔光」、「边缘光」、「暖色调」「中心构图」等关键词,模型可自动生成金色的落日余晖的浪漫画面;使用「冷色调」、「硬光」、「平衡图」、「低角度」的组合,则可以生成接近科幻片的画面效果

环境准备

CANN安装

# 增加软件包可执行权限,{version}表示软件版本号,{arch}表示CPU架构,{soc}表示昇腾AI处理器的版本。
chmod +x ./Ascend-cann-toolkit_{version}_linux-{arch}.run
chmod +x ./Ascend-cann-kernels-{soc}_{version}_linux.run

# 校验软件包安装文件的一致性和完整性
./Ascend-cann-toolkit_{version}_linux-{arch}.run --check
./Ascend-cann-kernels-{soc}_{version}_linux.run --check

# 安装
./Ascend-cann-toolkit_{version}_linux-{arch}.run --install
./Ascend-cann-kernels-{soc}_{version}_linux.run --install

# 设置环境变量
source /usr/local/Ascend/ascend-toolkit/set_env.sh

mindie安装

# 增加软件包可执行权限,{version}表示软件版本号,{arch}表示CPU架构。
chmod +x ./Ascend-mindie_${version}_linux-${arch}.run
./Ascend-mindie_${version}_linux-${arch}.run --check

# 方式一:默认路径安装
./Ascend-mindie_${version}_linux-${arch}.run --install
# 设置环境变量
cd /usr/local/Ascend/mindie && source set_env.sh

# 方式二:指定路径安装
./Ascend-mindie_${version}_linux-${arch}.run --install-path=${AieInstallPath}
# 设置环境变量
cd ${AieInstallPath}/mindie && source set_env.sh

Torch_npu安装

下载 pytorch_v{pytorchversion}_py{pythonversion}.tar.gz
tar -xzvf pytorch_v{pytorchversion}_py{pythonversion}.tar.gz
# 解压后,会有whl包
pip install torch_npu-{pytorchversion}.xxxx.{arch}.whl

模型权重

Wan2.2-T2V-A14B
https://huggingface.co/Wan-AI/Wan2.2-T2V-A14B/tree/main

Wan2.2-I2V-A14B
https://huggingface.co/Wan-AI/Wan2.2-I2V-A14B/tree/main

Wan2.2-TI2V-5B
https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B/tree/main

Wan2.2 支持分辨率说明

Wan2.2-T2V-A14B:720x1280,1280x720,480x832,832x480

Wan2.2-I2V-A14B:720x1280,1280x720,480x832,832x480

Wan2.2-TI2V-5B:704x1280,1280x704

模型离线推理

推理前准备

#  1. 下载代码
git clone https://modelers.cn/MindIE/Wan2.2.git

# 2. python相关依赖安装
pip install diffusers==0.35.1
pip install transformers==4.52.4
pip install yunchang==0.6.0

Wan2.2-T2V-A14B推理

等价优化

model_base="./Wan2.2-T2V-A14B/"
export ALGO=0
export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'
export TASK_QUEUE_ENABLE=2
export CPU_AFFINITY_CONF=1
export TOKENIZERS_PARALLELISM=false

torchrun --nproc_per_node=8 --master_port=23459 generate.py \
--task t2v-A14B \
--ckpt_dir ${model_base} \
--size 1280*720 \
--frame_num 81 \
--sample_steps 40 \
--dit_fsdp \
--t5_fsdp \
--cfg_size 2 \
--ulysses_size 4 \
--vae_parallel \
--prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." \
--base_seed 0

其中,参数详细描述如下:

  • ALGO: 为0表示默认FA算子; 设置为1表示使用高性能FA算子
  • task: 任务类型。
  • ckpt_dir: 模型的权重路径
  • size: 生成视频的分辨率,支持(1280,720)、(832,480)分辨率
  • frame_num: 生成视频的帧数
  • sample_steps: 推理步数
  • dit_fsdp: dit使能fsdp, 用以降低显存占用
  • t5_fsdp: t5使能fsdp, 用以降低显存占用
  • cfg_size: cfg并行数
  • ulysses_size: ulysses并行数
  • vae_parallel: 使能vae并行策略
  • prompt: 文本提示词
  • base_seed: 随机种子

Wan2.2-I2V-A14B推理

等价优化

model_base="./Wan2.2-I2V-A14B/"
export ALGO=0
export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'
export TASK_QUEUE_ENABLE=2
export CPU_AFFINITY_CONF=1
export TOKENIZERS_PARALLELISM=false

torchrun --nproc_per_node=8 generate.py \
--task i2v-A14B \
--ckpt_dir ${model_base} \
--size 1280*720 \
--frame_num 81 \
--sample_steps 40 \
--dit_fsdp \
--t5_fsdp \
--cfg_size 2 \
--ulysses_size 4 \
--vae_parallel \
--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." \
--base_seed 0

其中,参数详细描述如下:

  • ALGO: 为0表示默认FA算子; 设置为1表示使用高性能FA算子
  • task: 任务类型。
  • ckpt_dir: 模型的权重路径
  • size: 生成视频的分辨率,支持(1280,720)、(832,480)分辨率
  • frame_num: 生成视频的帧数
  • sample_steps: 推理步数
  • dit_fsdp: dit使能fsdp, 用以降低显存占用
  • t5_fsdp: t5使能fsdp, 用以降低显存占用
  • cfg_size: cfg并行数
  • ulysses_size: ulysses并行数
  • vae_parallel: 使能vae并行策略
  • image: 输入图片路径
  • prompt: 文本提示词
  • base_seed: 随机种子

Wan2.2-TI2V-5B推理

等价优化

model_base="./Wan2.2-TI2V-5B/"
export ALGO=0
export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'
export TASK_QUEUE_ENABLE=2
export CPU_AFFINITY_CONF=1
export TOKENIZERS_PARALLELISM=false

python generate.py \
--task ti2v-5B \
--ckpt_dir ${model_base} \
--size 1280*704 \
--frame_num 121 \
--sample_steps 50 \
--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." \
--offload_model False \
--base_seed 0

其中,参数详细描述如下:

  • ALGO: 为0表示默认FA算子;设置为1表示使用高性能FA算子
  • task: 任务类型。
  • ckpt_dir: 模型的权重路径
  • size: 生成视频的分辨率,支持(1280,720)、(832,480)分辨率
  • frame_num: 生成视频的帧数
  • sample_steps: 推理步数
  • image: 输入图片路径
  • prompt: 文本提示词
  • offload_model: 是否开启cpu offload,单卡默认开启
  • base_seed: 随机种子