当前位置: 首页 > news >正文

基于昇腾玩转电影级视频生成模型Wan 2.2

7月28日,阿里开源了新一代视频生成模型王者通义万相Wan2.2。此次共开源文生视频(Wan2.2-T2V-A14B)、图生视频(Wan2.2-I2V-A14B)和统一视频生成(Wan2.2-IT2V-5B)三款模型,其中文生视频模型和图生视频模型均为业界首个使用MoE架构的视频生成模型,总参数量为27B,激活参数14B;同时,首创电影美学控制系统,光影、色彩、构图、微表情等能力媲美专业电影水平。

昇腾支持该模型开箱部署和推理,模型已上线魔乐社区,欢迎下载体验!

🔗模型链接:

https://modelers.cn/models/MindIE/Wan2.2

01

模型介绍

Wan2.2模型将MoE(混合专家)架构实现到了视频生成扩散模型中!A14B版本由高噪专家模型低噪专家模型组成,考虑扩散模型的去噪过程存在阶段性差异,我们根据去噪时间步进行了专家模型划分——高噪声阶段关注生成视频的整体布局,低噪声阶段则更关注细节的完善。

图片

在生成视频时,噪声首先经过高噪专家模型进行前期去噪,再经过低噪专家模型进行后期去噪,高噪和低噪专家模型各自独立激活。因此Wan2.2生成的视频分布与真实视频差异更小,质量更高! 

Wan2.2还首创了电影美学控制系统,光影、色彩、构图、微表情等能力媲美专业电影水平。例如,用户输入「黄昏」、「柔光」、「边缘光」、「暖色调」「中心构图」等关键词,模型可自动生成金色的落日余晖的浪漫画面;使用「冷色调」、「硬光」、「平衡图」、「低角度」的组合,则可以生成接近科幻片的画面效果。

图片

图片

图片

通义万相还开源了一款5B小尺寸的统一视频生成模型,单一模型同时支持文生视频和图生视频,可在消费级显卡部署。该模型采用了高压缩率3D VAE架构,时间与空间压缩比达到高达 4×16×16,信息压缩率提升至 64,均实现了开源模型的最高水平,仅需22G显存(单张消费级显卡)即可在数分钟内生成5秒高清视频,是目前24帧每秒、720P像素级的生成速度最快的基础模型

以下为手把手推理教程。

02

准备运行环境

配套

版本

Python

3.11.10

torch

2.1.0

1. 获取CANN&MindIE安装包&环境准备

• 设备支持 Atlas 800I/800T A2(8*64G)推理设备:支持的卡数最小为1 Atlas 800I/800T A2(8*64G) 

(https://www.hiascend.com/developer/download/community/result?module=pt+ie+cann&product=4&model=32)

• 环境准备指导:

https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/softwareinst/instg/instg_0001.html

2. CANN安装

# 增加软件包可执行权限,{version}表示软件版本号,{arch}表示CPU架构,{soc}表示昇腾AI处理器的版本。chmod +x ./Ascend-cann-toolkit_{version}_linux-{arch}.runchmod +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

3. 环境依赖安装

pip3 install -r requirements.txt

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

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

03

下载权重

从魔乐社区或者HuggingFace下载权重:

Wan2.2-T2V-A14B: https://modelers.cn/models/Modelers_Park/Wan2.2-T2V-A14B 

Wan2.2-I2V-A14B: https://modelers.cn/models/Modelers_Park/Wan2.2-I2V-A14B  

Wan2.2-TI2V-5B: https://modelers.cn/models/Modelers_Park/Wan2.2-TI2V-5B 

04

Wan2.2使用

下载到本地

git clone https://modelers.cn/MindIE/Wan2.2.git

Wan2.2-T2V-A14B

使用上一步下载的权重:

model_base="./Wan2.2-T2V-A14B/"

等价优化:

8卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --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 1 \--ulysses_size 8 \--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: 随机种子

16卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=16 --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 8 \--vae_parallel \--prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." \--base_seed 0

Wan2.2-I2V-A14B

使用上一步下载的权重:

model_base="./Wan2.2-I2V-A14B/"

等价优化

8卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --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 1 \--ulysses_size 8 \--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: 随机种子

16卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=16 --master_port=23459 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 8 \--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

Wan2.2-TI2V-5B

使用上一步下载的权重:

model_base="./Wan2.2-TI2V-5B/"

等价优化 

单卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsepython 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." \--base_seed 0 

参数说明

• ALGO: 为0表示默认FA算子;设置为1表示使用高性能FA算子

• task: 任务类型

• ckpt_dir: 模型的权重路径

• size: 生成视频的分辨率,支持(1280,720)、(832,480)分辨率

• frame_num: 生成视频的帧数

• sample_steps: 推理步数

• image: 输入图片路径

• prompt: 文本提示词

• base_seed: 随机种子

8卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=8 generate.py \--task ti2v-5B \--ckpt_dir ${model_base} \--size 1280*704 \--frame_num 121 \--sample_steps 50 \--dit_fsdp \--t5_fsdp \--cfg_size 1 \--ulysses_size 8 \--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: 随机种子

16卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=16 --master_port=23459 generate.py \--task ti2v-5B \--ckpt_dir ${model_base} \--size 1280*704 \--frame_num 81 \--sample_steps 40 \--dit_fsdp \--t5_fsdp \--cfg_size 2 \--ulysses_size 8 \--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

算法优化 

单卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsepython 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." \--base_seed 0 \--use_attentioncache \--start_step 20 \--attentioncache_interval 2 \--end_step 47

参数说明

• ALGO: 为0表示默认FA算子;设置为1表示使用高性能FA算子

• use_attentioncache: 使能attentioncache策略

• start_step: cache开始的step

• attentioncache_interval: cache重计算间隔

• end_step: cache结束的step

8卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=8 generate.py \--task ti2v-5B \--ckpt_dir ${model_base} \--size 1280*704 \--frame_num 121 \--sample_steps 50 \--dit_fsdp \--t5_fsdp \--cfg_size 1 \--ulysses_size 8 \--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 \--use_attentioncache \--start_step 20 \--attentioncache_interval 2 \--end_step 47

16卡性能测试

执行命令

export ALGO=0export PYTORCH_NPU_ALLOC_CONF='expandable_segments:True'export TASK_QUEUE_ENABLE=2export CPU_AFFINITY_CONF=1export TOKENIZERS_PARALLELISM=falsetorchrun --nproc_per_node=16 --master_port=23459 generate.py \--task ti2v-5B \--ckpt_dir ${model_base} \--size 1280*704 \--frame_num 81 \--sample_steps 40 \--dit_fsdp \--t5_fsdp \--cfg_size 2 \--ulysses_size 8 \--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 \--use_attentioncache \--start_step 20 \--attentioncache_interval 2 \--end_step 47

注:

1. 若出现OOM, 可添加环境变量 export T5_LOAD_CPU=1,以降低显存占用

2. 当前仅TI2V支持attentioncache

05

推理结果参考

Atlas 800I A2 (8*64G) 64核(arm) 性能数据

图片

欢迎体验

教程中提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License。

如您在使用该模型的过程中,发现任何问题(包括但不限于功能问题、合规问题),可以在魔乐社区模型讨论区留言。

http://www.dtcms.com/a/343140.html

相关文章:

  • ES_索引的操作
  • 基础网络模型
  • 【矩池云】实现Pycharm远程连接,上传数据并解压缩
  • 为什么程序部署到线上,就无法读取环境变量了
  • B2B工业品制造业TOB大客户营销培训老师培训师唐兴通谈AI数字化销售AI销冠底层逻辑数字化转型创新增长业绩
  • MyBatis-Plus MetaObjectHandler的几个坑(主要是id字段)
  • 《AI智脉速递》2025 年 8 月15 日 - 21 日
  • JetBrains 内的 GitHub Copilot Agent Mode + MCP:从配置到实战
  • vmware安装centos7
  • 深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第二章知识点问答(21题)
  • A股大盘数据-20250821 分析
  • 领域驱动中IUnitOfWork是干什么的
  • 【StarRocks】-- SQL CTE 语法
  • 机器学习中的集成算法与 k 均值聚类算法概述
  • 机器学习5
  • 解决办法:Chrome插件不能用,这些扩展程序不再受支持,因此已停用
  • 动态寻北仪如何在矿用掘进机中进行应用?
  • 用Vue2和Echarts画图的基本流程
  • AI升级社区便民服务:AI办事小程序高效办证+应急系统秒响应,告别跑腿愁住得更安心
  • K8s快速上手-微服务篇
  • AI资深 Java 研发专家系统解析Java 中常见的 Queue实现类
  • 【尝试】在macOS上安装cvat
  • unity实现点击rawimage,确定对应的世界坐标点
  • 记录前端菜鸟的日常——小程序内嵌H5页面自定义分享按钮
  • 环形子数组的最大和
  • Ubuntu24.04 交叉编译libuv库(已编译好的) 之undefined reference to `pthread_getname_np‘解决
  • VMware Workstation里的Ubuntu22.04找不到共享文件夹
  • Ubuntu Server 安装 gvm 管理 Go 语言开发环境
  • 代码随想录Day58:图论(拓扑排序精讲、最短路算法dijkstra朴素版精讲)
  • Android焦点窗口变化导致遥控键值监听失效问题分析