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

news2025/3/10 13:44:06

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

七、下载模型文件

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 --prompt "A cute little cat is cooking."

九、图生视频测试

单GPU情况下指令如下:

python generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/test.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."

十、文生图片测试

python generate.py --task t2v-1.3B --size 480*832 --ckpt_dir ./Wan2.1-T2V-1.3B --prompt '一个漂亮的女孩' --save_file output --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.coloradmin.cn/o/2312718.html

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

相关文章

好玩的谷歌浏览器插件-自定义谷歌浏览器光标皮肤插件-Chrome 的自定义光标

周末没有啥事 看到了一个非常有意思的插件 就是 在使用谷歌浏览器的时候,可以把鼠标的默认样式换一个皮肤。就像下面的这种样子。 实际谷歌浏览器插件开发对于有前端编程基础的小伙伴 还是比较容易的,实际也是写 html css js 。 所以这个插件使用的技术…

svn删除所有隐藏.svn文件,文件夹脱离svn控制

新建一个文件,取名remove-svn-folders.reg,输入如下内容: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN] "Delete SVN Folders" [HKEY_LOCAL_MACHINE\SOFTWARE\Class…

六十天前端强化训练之第十二天之闭包深度解析

欢迎来到编程星辰海的博客讲解 目录 第一章:闭包的底层运行机制 1.1 词法环境(Lexical Environment)的构成JavaScript 引擎通过三个关键组件管理作用域: 1.2 作用域链的创建过程当函数被定义时: 1.3 闭包变量的生命…

DeepSeek R1-32B医疗大模型的完整微调实战分析(全码版)

DeepSeek R1-32B微调实战指南 ├── 1. 环境准备 │ ├── 1.1 硬件配置 │ │ ├─ 全参数微调:4*A100 80GB │ │ └─ LoRA微调:单卡24GB │ ├── 1.2 软件依赖 │ │ ├─ PyTorch 2.1.2+CUDA │ │ └─ Unsloth/ColossalAI │ └── 1.3 模…

10.2 继承与多态

文章目录 继承多态 继承 继承的作用是代码复用。派生类自动获得基类的除私有成员外的一切。基类描述一般特性,派生类提供更丰富的属性和行为。在构造派生类时,其基类构造函数先被调用,然后是派生类构造函数。在析构时顺序刚好相反。 // 基类…

[网络爬虫] 动态网页抓取 — Selenium 元素定位

🌟想系统化学习爬虫技术?看看这个:[数据抓取] Python 网络爬虫 - 学习手册-CSDN博客 在使用 Selenium 时,往往需要先定位到指定元素,然后再执行相应的操作。例如,再向文本输入框中输入文字之前,…

静态网页的爬虫(以电影天堂为例)

一、电影天堂的网址(url) 电影天堂_免费电影_迅雷电影下载_电影天堂网最好的迅雷电影下载网,分享最新电影,高清电影、综艺、动漫、电视剧等下载!https://dydytt.net/index.htm 我们要爬取这个页面上的内容 二、代码…

Android设备是如何进入休眠的呢?

首先我们手机灭屏后,一般需要等一段时间CPU才真正进入休眠。即Android设备屏幕暗下来的时候,并不是立即就进入了休眠模式;当所有唤醒源都处于de-avtive状态后,系统才会进入休眠。在手机功耗中从灭屏开始到CPU进入休眠时间越短&…

ctfshow做题笔记—栈溢出—pwn65~pwn68

目录 前言 一、pwn65(你是一个好人) 二、pwn66(简单的shellcode?不对劲,十分得有十二分的不对劲) 三、pwn67(32bit nop sled)(确实不会) 四、pwn68(64bit nop sled) 前言 做起来比较吃力哈哈,自己还是太菜了&…

JS中的闭包(closures)一种强大但易混淆的概念

JavaScript 中的闭包(closures)被认为是一种既强大又易混淆的概念。闭包允许函数访问其外部作用域的变量,即使外部函数已执行完毕,这在状态维护和回调函数中非常有用。但其复杂性可能导致开发者的误解,尤其在变量捕获和…

Element使用

Element(美化网页&#xff09; ElementUI的使用注意事项&#xff1a; Element.ui的使用基于Vue环境&#xff0c;于是Element相关组件的使用必须放在Vue对象绑定的视图中去 ElementUI的JS库的引入必须放在vue.js库的后面 <!-- 引入样式 --><link rel"styleshee…

基于YOLO11深度学习的电瓶车进电梯检测与语音提示系统【python源码+Pyqt5界面+数据集+训练代码】

《------往期经典推荐------》 一、AI应用软件开发实战专栏【链接】 项目名称项目名称1.【人脸识别与管理系统开发】2.【车牌识别与自动收费管理系统开发】3.【手势识别系统开发】4.【人脸面部活体检测系统开发】5.【图片风格快速迁移软件开发】6.【人脸表表情识别系统】7.【…

R语言的基础命令及实例操作

> T & F [1] FALSE > T & T [1] TRUE > T | F [1] TRUE > F | F [1] FALSE > a <- c(T,F,T) > b <- c(F,F,T) > a & b [1] FALSE FALSE TRUE > a | b [1] TRUE FALSE TRUE 在 R 中&#xff0c;大小写是敏感的&#xff0c;也就是说…

知识蒸馏综述Knowledge Distillation: A Survey解读

论文链接&#xff1a;Knowledge Distillation: A Survey 摘要&#xff1a;近年来&#xff0c;深度神经网络在工业界和学术界都取得了成功&#xff0c;尤其是在计算机视觉任务方面。深度学习的巨大成功主要归功于它能够扩展以对大规模数据进行编码&#xff0c;并且能够处理数十…

第十五届蓝桥杯省赛电子类单片机学习过程记录(客观题)

客观试题: 01.典型的BUCK电源电路包含哪些关键器件(ABCD) A. 电容 B. 二极管 C. 电感 D. MOSFET 解析: 典型的 BUCK 电源电路是一种降压型的直流-直流转换电路,它包含以下关键器件: A.电容:电容在电路中起到滤波的作用。输入电容用于平滑输入电压的波动,减少电源噪声对…

【c++】平移字符串

说明 实现字符串的左移与右移 示例代码 #include <iostream> #include <string> using namespace std;int main() {string str1 "12345";//左移2位string str2 str1.substr(2) str1.substr(0, 2);cout << str2 << endl;//右移2位&…

为什么DDPG需要目标网络而A2C不需要?

在强化学习中&#xff0c;DDPG需要目标网络而A2C不需要的主要原因在于算法架构、更新方式和目标稳定性需求的差异&#xff1a; Q值估计的稳定性需求不同 DDPG的Critic网络需要估计状态-动作值函数 Q ( s , a ) Q(s,a) Q(s,a)&#xff0c;其目标值的计算涉及下一个状态的最大Q值…

蓝桥杯 C++ b组 统计子矩阵深度解析

题目大意&#xff1a;给定一个 NM 的矩阵 A&#xff0c;请你统计有多少个子矩阵 (最小11&#xff0c;最大NM) 满足子矩阵中所有数的和不超过给定的整数 K&#xff1f; 前言&#xff1a;这题很容易想到二维前缀和优化&#xff0c;然后枚举子矩阵&#xff0c;但这样时间复杂度为…

YOLOv12本地部署教程——42%速度提升,让高效目标检测触手可及

YOLOv12 是“你只看一次”&#xff08;You Only Look Once, YOLO&#xff09;系列的最新版本&#xff0c;于 2025 年 2 月发布。它引入了注意力机制&#xff0c;提升了检测精度&#xff0c;同时保持了高效的实时性能。在保持速度的同时&#xff0c;显著提升了检测精度。例如&am…

认识Event Loop【1】

前言 这应该是一个系列文章&#xff0c;因为我觉得Event Loop&#xff08;事件循环&#xff09;是一件很抽象也很重要的一个机制。eventloop这个知识点处于非常杂糅的位置&#xff0c;和很多其他知识&#xff0c;如运行时、浏览器、渲染流程、数据结构、线程等等&#xff0c;也…