通义万相2.1开源版本地化部署攻略,生成视频再填利器

2025 年 2 月 25 日晚上 11:00 通义万相 2.1 开源发布,前两周太忙没空搞它,这个周末,也来本地化部署一个,体验生成效果如何,总的来说,它在国内文生视频、图生视频的行列处于领先位置,同时也支持文生图。

一、开源代码下载来源

GitHub:https://github.com/Wan-Video/Wan2.1

这个源码包中可以做的事包括:

Wan2.1 Text-to-Video
 Multi-GPU Inference code of the 14B and 1.3B models
 Checkpoints of the 14B and 1.3B models
 Gradio demo
 ComfyUI integration
 Diffusers integration
 Diffusers + Multi-GPU Inference
Wan2.1 Image-to-Video
 Multi-GPU Inference code of the 14B model
 Checkpoints of the 14B model
 Gradio demo
 ComfyUI integration
 Diffusers integration
 Diffusers + Multi-GPU Inference

以下相关网址,有在线体验的,有可以下载配套模型的,也有可以下载源码的,根据需要自行选择,访问国外的网站请提前准备好科学上网。

官网:https://tongyi.aliyun.com/wanxiang/

博客:https://wanxai.com/

Modelscope:https://modelscope.cn/organization/Wan-AI

Hugging Face:https://huggingface.co/Wan-AI

二、下载python虚拟环境管理软件,安装较新版的python

下载地址:https://docs.conda.io/en/latest/miniconda.html

安装好后打开它,最好使用管理员模式打开。

依次敲入指令,创建并激活项目所需的虚拟环境。(关于conda的使用方法会单独出一篇教程,这里就不多解释了)

conda create --name Wan21 python=3.12.9

三、安装git

https://git-scm.com/

验证安装成功如下:

四、安装cuda

到官网CUDA Toolkit Archive | NVIDIA Developer 下载驱动,按提示安装。这里需要为自己的显卡选择具体的版本,命令行输入指令nvidia-smi查看对应版本。

下载后安装完配置一下环境变量

五、下载万象2.1源码

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

六、安装万象2.1所需的依赖包

到conda的虚拟环境中来安装,给万象2.1配置专用的python运行环境。

conda activate Wan21

看看这个依赖源的清单,数量不多,建议还是手工一条条安装,以便看到哪一个在安装中出问题了,定向解决。

很多时候用上面的清单安装后,torch版本不支持cuda,可以参照下面这个网址,找到对应的版本去下载。

https://github.com/facebookresearch/xformers#installing-xformers

有时运行还会报错,缺少flash-attn依赖,可以根据对应的torch版本下载这个依赖包,不过编译的时间好长,只要不报错,一定要耐心等待,我可是等了半天多才完成编译。

我最终的依赖包清单如下:

(wanvideo21) F:\GitProject\Wan2.1>pip list
Package            Version
------------------ ------------
accelerate         1.4.0
aiofiles           23.2.1
aiohappyeyeballs   2.5.0
aiohttp            3.11.13
aiosignal          1.3.2
annotated-types    0.7.0
anyio              4.8.0
attrs              25.1.0
certifi            2025.1.31
charset-normalizer 3.4.1
click              8.1.8
colorama           0.4.6
dashscope          1.22.1
diffusers          0.32.2
easydict           1.13
einops             0.8.1
fastapi            0.115.11
ffmpy              0.5.0
filelock           3.17.0
flash_attn         2.7.3
frozenlist         1.5.0
fsspec             2025.2.0
ftfy               6.3.1
gradio             5.20.0
gradio_client      1.7.2
groovy             0.1.2
h11                0.14.0
httpcore           1.0.7
httpx              0.28.1
huggingface-hub    0.29.2
idna               3.10
imageio            2.37.0
imageio-ffmpeg     0.6.0
importlib_metadata 8.6.1
intel-openmp       2021.4.0
Jinja2             3.1.6
markdown-it-py     3.0.0
MarkupSafe         2.1.5
mdurl              0.1.2
mkl                2021.4.0
mpmath             1.3.0
multidict          6.1.0
networkx           3.4.2
numpy              1.26.0
opencv-python      4.11.0.86
orjson             3.10.15
packaging          24.2
pandas             2.2.3
pillow             11.1.0
pip                25.0.1
propcache          0.3.0
psutil             7.0.0
pydantic           2.10.6
pydantic_core      2.27.2
pydub              0.25.1
Pygments           2.19.1
python-dateutil    2.9.0.post0
python-multipart   0.0.20
pytz               2025.1
PyYAML             6.0.2
regex              2024.11.6
requests           2.32.3
rich               13.9.4
ruff               0.9.9
safehttpx          0.1.6
safetensors        0.5.3
semantic-version   2.10.0
setuptools         75.8.2
shellingham        1.5.4
six                1.17.0
sniffio            1.3.1
starlette          0.46.0
sympy              1.13.1
tbb                2021.11.0
tokenizers         0.21.0
tomlkit            0.13.2
torch              2.6.0+cu126
torchaudio         2.6.0+cu126
torchvision        0.21.0+cu126
tqdm               4.67.1
transformers       4.49.0
typer              0.15.2
typing_extensions  4.12.2
tzdata             2025.1
urllib3            2.3.0
uvicorn            0.34.0
wcwidth            0.2.13
websocket-client   1.8.0
websockets         15.0.1
wheel              0.45.1
yarl               1.18.3
zipp               3.21.0

七、下载模型文件

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

因为模型文件比较大,这个根据网速情况,会有些慢 。如果发现下载速度变慢了,可以ctrl+c终止后重新启动。

模型文件种类:

八、文生视频测试

单GPU情况下指令如下:

python generate.py  --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --save_file output --prompt "A cute little cat is cooking."

如果显存不够大,会报“Out-of-Memory”错误,可以使用参数--offload_model True and --t5_cpu启用cpu计算,同时改用小点的模型,使用低分辨率的像素来生成。

python generate.py --task t2v-1.3B --size 480*832 --ckpt_dir ./Wan2.1-T2V-1.3B --offload_model True --t5_cpu --sample_shift 8 --sample_guide_scale 6 --save_file ./output/test1.mp4 --prompt "A cute little cat is cooking."

九、图生视频测试

单GPU情况下指令如下:

python generate.py --task t2v-1.3B --size 480*832 --ckpt_dir ./Wan2.1-T2V-1.3B --offload_model True --t5_cpu --image ./examples/test.jpg --save_file ./output/test2.mp4 --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."

十、文生图片测试

python generate.py --task t2v-1.3B --size 480*832 --ckpt_dir ./Wan2.1-T2V-1.3B --prompt '一个漂亮的女孩' --offload_model True --t5_cpu

结果生成的还是视频。

想看指令可以带哪些参数,可以查看源码文件generate.py,其中片段如下:

def _parse_args():parser = argparse.ArgumentParser(description="Generate a image or video from a text prompt or image using Wan")parser.add_argument("--task",type=str,default="t2v-14B",choices=list(WAN_CONFIGS.keys()),help="The task to run.")parser.add_argument("--size",type=str,default="1280*720",choices=list(SIZE_CONFIGS.keys()),help="The area (width*height) of the generated video. For the I2V task, the aspect ratio of the output video will follow that of the input image.")parser.add_argument("--frame_num",type=int,default=None,help="How many frames to sample from a image or video. The number should be 4n+1")parser.add_argument("--ckpt_dir",type=str,default=None,help="The path to the checkpoint directory.")parser.add_argument("--offload_model",type=str2bool,default=None,help="Whether to offload the model to CPU after each model forward, reducing GPU memory usage.")parser.add_argument("--ulysses_size",type=int,default=1,help="The size of the ulysses parallelism in DiT.")parser.add_argument("--ring_size",type=int,default=1,help="The size of the ring attention parallelism in DiT.")parser.add_argument("--t5_fsdp",action="store_true",default=False,help="Whether to use FSDP for T5.")parser.add_argument("--t5_cpu",action="store_true",default=False,help="Whether to place T5 model on CPU.")parser.add_argument("--dit_fsdp",action="store_true",default=False,help="Whether to use FSDP for DiT.")parser.add_argument("--save_file",type=str,default=None,help="The file to save the generated image or video to.")parser.add_argument("--prompt",type=str,default=None,help="The prompt to generate the image or video from.")parser.add_argument("--use_prompt_extend",action="store_true",default=False,help="Whether to use prompt extend.")parser.add_argument("--prompt_extend_method",type=str,default="local_qwen",choices=["dashscope", "local_qwen"],help="The prompt extend method to use.")parser.add_argument("--prompt_extend_model",type=str,default=None,help="The prompt extend model to use.")parser.add_argument("--prompt_extend_target_lang",type=str,default="zh",choices=["zh", "en"],help="The target language of prompt extend.")parser.add_argument("--base_seed",type=int,default=-1,help="The seed to use for generating the image or video.")parser.add_argument("--image",type=str,default=None,help="The image to generate the video from.")parser.add_argument("--sample_solver",type=str,default='unipc',choices=['unipc', 'dpm++'],help="The solver used to sample.")parser.add_argument("--sample_steps", type=int, default=None, help="The sampling steps.")parser.add_argument("--sample_shift",type=float,default=None,help="Sampling shift factor for flow matching schedulers.")parser.add_argument("--sample_guide_scale",type=float,default=5.0,help="Classifier free guidance scale.")args = parser.parse_args()_validate_args(args)return args

体验感受:总的来说万象生成的视频质量还是不错的,最大的亮点是它原生支持中文提示词,对大部分的同胞们来说这是个福音。只不过这玩意太耗显存,看下面官方给出的测试报告就知道了,起步是4090,也进一步验证了智能时代拼的是算力。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/71864.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux——system V共享内存

共享内存区是最快的IPC(进程内通信)形式,不再通过执行进入内核的系统调用来传递彼此的数据 1.共享内存的原理 IPC通信的本质是让不同的进程先看到同一份资源,然后再进行通信,所以想要通过共享内存进行通信,那么第一步一定是让两个…

01 SQl注入基础步骤(数字、字符、布尔盲注、报错)

目录 1、SQL注入漏洞的概要 2、SQL注入的常规思路 3、数字型注入 4、字符型注入 5、布尔盲注 6、报错注入 1、SQL注入漏洞的概要 原理:通过用户输入的数据未严格过滤,将恶意SQL语句拼接到原始查询中,从而操控数据库执行非预期操作。 …

leetcode-sql数据库面试题冲刺(高频SQL五十题)

题目: 620.有趣的电影 表:cinema ------------------------ | Column Name | Type | ------------------------ | id | int | | movie | varchar | | description | varchar | | rating | float | ------------------------ id 是该表的主键(具有唯一值…

7.2 奇异值分解的基与矩阵

一、奇异值分解 奇异值分解(SVD)是线性代数的高光时刻。 A A A 是一个 m n m\times n mn 的矩阵,可以是方阵或者长方形矩阵,秩为 r r r。我们要对角化 A A A,但并不是把它化成 X − 1 A X X^{-1}A X X−1AX 的形…

在本地部署DeepSeek等大模型时,需警惕的潜在安全风险

在本地部署DeepSeek等大模型时,尽管数据存储在本地环境(而非云端),但仍需警惕以下潜在安全风险: 1. 模型与数据存储风险 未加密的存储介质:若训练数据、模型权重或日志以明文形式存储,可能被物…

【javaEE】多线程(进阶)

1.❤️❤️前言~🥳🎉🎉🎉 Hello, Hello~ 亲爱的朋友们👋👋,这里是E绵绵呀✍️✍️。 如果你喜欢这篇文章,请别吝啬你的点赞❤️❤️和收藏📖📖。如果你对我的…

dify中使用NL2SQL

在 Dify 工作流中融入 NL2SQL(自然语言转 SQL)之能力,可依循如下步骤达成,借由 Dify 的模块化设计以及模型编排之功能,优化数据库查询之智能化交互: 一、环境准备与 Dify 部署 安装 Docker 与 Dify 务须确…

使用Everything搜索指定文件夹中的内容

直接路径搜索法 在 Everything 的搜索框中输入文件夹路径加空格,再输入要搜索的内容或文件名。如要在 D 盘的 “文档” 文件夹中搜索名为 “报告.docx” 的文件,可输入 “D:\ 文档 报告.docx”235。 高级搜索法 打开 Everything 软件,点击菜…

Java在小米SU7 Ultra汽车中的技术赋能

目录 一、智能驾驶“大脑”与实时数据 场景一:海量数据的分布式计算 场景二:实时决策的毫秒级响应 场景三:弹性扩展与容错机制 技术隐喻: 二、车载信息系统(IVI)的交互 场景一:Android Automo…

Vue开发中计算属性与方法调用之间的区别与联系

文章目录 一 概述二 核心区别三 联系四 使用原则 一 概述 在 Vue 中,计算属性(computed) 和 方法(methods) 都可以用于处理数据逻辑,但它们的核心区别在于 缓存机制 和 触发方式 。 计算属性示例&#xf…

【Unity】 HTFramework框架(六十一)Project窗口文件夹锁定器

更新日期:2025年3月7日。 Github源码:[点我获取源码] Gitee源码:[点我获取源码] 索引 Project窗口文件夹锁定器框架文件夹锁定自定义文件夹锁定限制条件 Project窗口文件夹锁定器 在Project窗口中,文件夹锁定器能够为任何文件夹加…

C语言:6.20字符型数据练习题

编写程序,输人一行数字字符(用回车结束),每个数字字符 的前后都有空格。 把这一行中的数字转换成一个整数。 例如,若输入(<CR>代表 Enter键):2 4 8 3<CR>则输出 整数:2483。 #include <stdio.h>int main() {char ch;int number 0;printf("请输入一行…

【软件工程】一篇入门UML建模图(状态图、活动图、构件图、部署图)

&#x1f308; 个人主页&#xff1a;十二月的猫-CSDN博客 &#x1f525; 系列专栏&#xff1a; &#x1f3c0;软件开发必练内功_十二月的猫的博客-CSDN博客 &#x1f4aa;&#x1f3fb; 十二月的寒冬阻挡不了春天的脚步&#xff0c;十二点的黑夜遮蔽不住黎明的曙光 目录 1. 前…

【C语言】数组篇

目录 引言一维数组数组的定义数组的初始化完全初始化部分初始化省略数组长度 数组元素的访问 多维数组二维数组的定义二维数组的初始化完全初始化部分初始化省略第一维长度 二维数组元素的访问 遍历数组元素遍历一维数组遍历二维数组 数组作为函数参数一维数组作为函数参数二维…

OpenCV视频解码性能优化十连击(实测帧率提升300%)

解密工业级视频处理优化方案&#xff01;从硬件加速到多线程榨干CPU/GPU性能&#xff0c;附RTSP流调优参数与内存泄漏排查技巧。 &#x1f527; 优化前准备 环境检测脚本 import cv2# 验证硬件加速支持 print("CUDA支持:", cv2.cuda.getCudaEnabledDeviceCount() &…

基于编译器特性浅析C++程序性能优化

最近在恶补计算机基础知识&#xff0c;学到CSAPP第五章的内容&#xff0c;在这里总结并且展开一下C程序性能优化相关的内容。 衡量程序性能的方式 一般而言&#xff0c;程序的性能可以用CPE&#xff08;Cycles Per Element&#xff09;来衡量&#xff0c;其指的是处理每个元素…

transformer模型介绍——大语言模型 LLMBook 学习(二)

1. transformer模型 1.1 注意力机制 **注意力机制&#xff08;Attention Mechanism&#xff09;**在人工智能中的应用&#xff0c;实际上是对人类认知系统中的注意力机制的一种模拟。它主要模仿了人类在处理信息时的选择性注意&#xff08;Selective Attention&#xff09;&a…

word甲烷一键下标

Sub 甲烷下标()甲烷下标 宏Selection.Find.ClearFormattingSelection.Find.Replacement.ClearFormattingWith Selection.Find.Text "CH4".Replacement.Text "CHguoshao4".Forward True.Wrap wdFindContinue.Format False.MatchCase False.MatchWhole…

Dify 本地部署教程

目录 一、下载安装包 二、修改配置 三、启动容器 四、访问 Dify 五、总结 本篇文章主要记录 Dify 本地部署过程,有问题欢迎交流~ 一、下载安装包 从 Github 仓库下载最新稳定版软件包,点击下载~,当然也可以克隆仓库或者从仓库里直接下载zip源码包。 目前最新版本是V…

2.1 掌握XML基础知识

本文介绍了结构化、半结构化和非结构化数据的概念与特点。结构化数据以固定格式存储于数据库&#xff0c;便于查询与管理&#xff0c;常用于金融等领域。半结构化数据如XML、JSON&#xff0c;具有一定的组织形式但模式不固定&#xff0c;适用于Web内容和日志文件。非结构化数据…