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

【1分钟学会万相文生视频】windows环境4080显卡部署Wan2.1-T2V-1.3B,亲手实操

开源的风吹到视频生成:阿里开源登顶VBench的万相大模型

  • 1.先从github上下载源码,或者下载zip解压:
  • 2.下载模型
  • 3.按照官方指令进行推理
  • 4.输入prompt,生成对应的视频

=话不多说,看看标题就知道:=

1.先从github上下载源码,或者下载zip解压:

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

2.下载模型

from modelscope import snapshot_download

# 指定模型名称
model_name = "Wan-AI/Wan2.1-T2V-1.3B"

# 指定下载路径(绝对路径)
custom_path = "Wan2.1-T2V-1.3B"

# 下载模型
model_dir = snapshot_download(
     model_name,  # 模型名称
     cache_dir=custom_path,  # 指定下载路径
    revision="master"  # 可选:指定模型版本(默认master)
 )

 print(f"模型已下载到:{model_dir}")

3.按照官方指令进行推理

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

本人做了三个个改动:
1.用–t5_cpu参数会将文本编码器放到CPU上跑,但是在CPU上跑文本编码也是很慢的,因此先在GPU上跑,然后在源码上torch.cuda.empty_cache()清理掉缓存,就快了很多
在这里插入图片描述
2.由于很多机器,比如V100或者2080Ti,或多或少都不支持flash_attention。只需要在源码的model.py将flash_attention替换成from .attention import attention as flash_attention就可以了

# 源码
# from .attention import flash_attention
#替换成
from .attention import attention as flash_attention

3.这个一个意想不到的问题,windows上不支持用号明明文件,如果用源码跑完会保存不了mp4,因此需要将替换掉。如在generate.py文件中将*号替换成X

args.save_file = args.save_file.replace("*", "X")

4.输入prompt,生成对应的视频

prompt:

In a realistic close-up shot with smooth camera movement, a charming woman is seen outdoors on a grassy lawn. She is wearing a white shirt paired with a white jacket, and she adorns a necklace and earrings, adding elegance to her appearance. The woman is gracefully walking around an area enclosed by a wooden fence, moving in a gentle arc as she walks past the fence. The background features a lush green lawn and tent-like structures, creating a serene and refreshing atmosphere. The lighting is ample, highlighting the natural beauty of the scene.

效果视频:
在这里插入图片描述
在这里插入图片描述

相关文章:

  • 【STL】7.STL常用算法(1)
  • miqiu的分布式锁(二):实战——用JMeter验证JVM锁能否解决MySQL超卖问题
  • element-ui的组件使用
  • 每日一题——字母异位词分组
  • 2024 年出现的 11 大数据收集趋势
  • spring boot 连接FTP实现文件上传
  • linux中根目录满了
  • C#开发的Base64编码及解码完整源码及注意事项
  • 【含开题报告+文档+PPT+源码】基于大数据的交通流量预测系统
  • 论软件设计模式及其应用-软考
  • 【算法】797. 差分
  • C语言番外篇(4)--------->goto语句
  • 如何进行OceanBase 运维工具的部署和表性能优化
  • Linux 内核配置机制详细讲解
  • 【Jenkins】一种灵活定义多个执行label节点的jenkinsfile写法
  • 【由技及道】模块化战争与和平-论项目结构的哲学思辨【人工智智障AI2077的开发日志】
  • 【c++】【线程池】固定式线程池(FixedThreadPool)
  • 解锁C# XML编程:从新手到实战高手的蜕变之路
  • Document对象
  • 【组态PLC】基于西门子S7-200和博图V16和组态王十层起重机电梯设计【含PLC组态源码 M018期】
  • 哪个网站做视频有钱挣/建网站专业
  • 做公司网站的企业/百度推广深圳分公司
  • 免费的网站域名和空间/域名查询ip爱站网
  • 怎么开通自己的微信公众号/百度seo排名点击软件
  • 完整网站开发视频教程/西安seo顾问培训
  • 动态公司网站设计/昆明seo优化