开源视频生成模型Pyramid Flow本地部署实测
创作时间:
作者:
@小白创作中心
开源视频生成模型Pyramid Flow本地部署实测
引用
CSDN
1.
https://blog.csdn.net/u010522887/article/details/143279061
Pyramid Flow是一个开源的视频生成模型,具有参数量小、分辨率高、生成速度快等特点。本文将详细介绍如何在本地部署Pyramid Flow,并通过实测来验证其效果。
Pyramid Flow简介
项目地址:https://github.com/jy0205/Pyramid-Flow
Pyramid Flow的主要亮点包括:
- 仅需2B参数,即可生成768p分辨率、24fps的10秒视频
- 支持“文本到视频”和“图像到视频”两种模式
- 采用自回归生成方式,基于先前帧预测后续帧,确保视频内容的连贯性
- 采用金字塔式的多尺度架构,生成效率更高
根据官方评测结果,除了语义得分(semantic score)外,其他指标均优于开源方案CogVideo。
在线体验
Pyramid Flow已在Hugging Face上线,可以直接在线体验:
- 在线体验地址:https://huggingface.co/spaces/Pyramid-Flow/pyramid-flow
- 官方生成样例:https://pyramid-flow.github.io/
接下来,我们将详细介绍如何在本地部署Pyramid Flow。
本地部署
环境准备
首先需要准备Pyramid Flow的运行环境:
git clone https://github.com/jy0205/Pyramid-Flow
cd Pyramid-Flow
conda create -n pyramid python==3.8.10
conda activate pyramid
pip install -r requirements.txt
然后下载模型权重到本地:
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download rain1011/pyramid-flow-sd3 --local-dir ckpts/
模型权重包括768p和384p两种版本。384p版本支持5秒长的24FPS视频,而768p版本则可以生成10秒视频。
推理测试
加载模型:
import os
import torch
from PIL import Image
from pyramid_dit import PyramidDiTForVideoGeneration
from diffusers.utils import export_to_video
os.environ['CUDA_VISIBLE_DEVICES'] = '2'
model = PyramidDiTForVideoGeneration('ckpts/', 'bf16', model_variant='diffusion_transformer_384p')
model.vae.enable_tiling()
# model.vae.to("cuda")
# model.dit.to("cuda")
# model.text_encoder.to("cuda")
# if you're not using sequential offloading bellow uncomment the lines above ^
model.enable_sequential_cpu_offload()
如果将模型全部加载到GPU,至少需要19GB显存。建议采用上述代码以节省显存。
测试文本生成视频:
def t2v():
prompt = "A movie trailer featuring the adventures of the 30 year old space man wearing a red wool knitted motorcycle helmet, blue sky, salt desert, cinematic style, shot on 35mm film, vivid colors"
with torch.no_grad(), torch.amp.autocast('cuda', dtype=torch.bfloat16):
frames = model.generate(
prompt=prompt,
num_inference_steps=[20, 20, 20],
video_num_inference_steps=[10, 10, 10],
height=384,
width=640,
temp=16, # temp=16: 5s, temp=31: 10s
guidance_scale=9.0, # The guidance for the first frame, set it to 7 for 384p variant
video_guidance_scale=5.0, # The guidance for the other video latent
output_type="pil",
save_memory=True, # If you have enough GPU memory, set it to `False` to improve vae decoding speed
)
export_to_video(frames, "./text_to_video_sample.mp4", fps=24)
测试图片生成视频:
def i2v():
image = Image.open('assets/the_great_wall.jpg').convert("RGB").resize((640, 384))
prompt = "FPV flying over the Great Wall"
with torch.no_grad(), torch.amp.autocast('cuda', dtype=torch.bfloat16):
frames = model.generate_i2v(
prompt=prompt,
input_image=image,
num_inference_steps=[10, 10, 10],
temp=16,
video_guidance_scale=4.0,
output_type="pil",
save_memory=True, # If you have enough GPU memory, set it to `False` to improve vae decoding speed
)
export_to_video(frames, "./image_to_video_sample.mp4", fps=24)
Pyramid Flow对显存要求较高,生成5秒视频至少需要13分钟:
100%|████| 16/16 [13:11<00:00, 49.45s/it]
实测效果
实测结果显示,Pyramid Flow的效果并未与CogVideo拉开明显差距。
总结
本文介绍了如何本地部署最新开源的视频生成模型Pyramid Flow。虽然AI视频生成技术在不断发展,但目前的效果仍需进一步提升。如果你对AI视频生成感兴趣,欢迎尝试部署并探索更多可能性。
热门推荐
降雪叠加施工影响,G1京哈高速部分路段实施交通管制
春节高速免费通行,大连这些路段需注意!
李宇春连续20年跨年零点压轴,续写音乐传奇与舞台新篇章
芹菜食疗方助你养生,轻松搞定高血压!
香芹瘦肉炒出健康美味
专家推荐:芹菜叶汤改善心血管健康
如何设置谷歌浏览器的隐私保护
无氧呼吸与缺血性疾病:最新研究进展与临床应用
白月光:一个文化符号的多重解读
白月光是什么意思
狮子面相的特点与性格解析
微信支付与支付宝支付原理及区别
春节自驾游浙江:西湖、千岛湖、绍兴必打卡!
品味浙江年味:传统美食与特色活动全攻略
颈动脉斑块怎么锻炼
颈动脉斑块怎么锻炼
东方甄选回应超量使用虾药指控,虾药焦亚硫酸钠对健康有哪些危害
都市乌鸫早起之谜:光污染与噪音污染的双重影响
孙俪爆《甄嬛传》幕后趣事:惊鸿舞脖子落枕
《甄嬛传》揭秘:清宫妃嫔的真实生活
西湖十景打卡攻略:四季如画
雷峰塔亮灯后更美!杭州西湖一日游新攻略
杭州西湖:千年文化积淀的东方明珠
斯巴鲁漏洞事件引发关注:车牌号隐私保护迫在眉睫
MY车牌号归属地查询:广东21城车牌全解析
中央空调保养内容有哪些项目?
热水器买什么样的好?家里建议装哪种热水器?
糖尿病患者的心理支持,建立强大的社会网络
西安大唐不夜城亲子游:穿越千年的文化盛宴
大唐不夜城:西安必打卡网红景点