开源视频生成模型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视频生成感兴趣,欢迎尝试部署并探索更多可能性。
热门推荐
KET阅读题型展示、考察内容及解题要点全解析!
三国春节:铜雀台的真正由来,与赤壁之战无关!
车辆查封原因全解析,保障您的行车安全
镁在睡眠健康中的作用
红枣对胃病有益?深入这3种食物,避免无意间给胃病患者增加负担
亲子共读的高质量绘本 火遍小朋友圈的屁屁侦探系列丛书很值得一读
瘦人健身增肌方法
私家车加入滴滴是否合法且安全?
消费者权益有哪些,消费者权利有几种
《儒林外史》的写作与流传
全麦面包里的“健康密码”
“共赏黄梅韵味,领略戏曲魅力”--暑期社会实践黄梅分队
新概念无人机首飞,“变形金刚”理念重生
三个最伤颈椎的姿势,医生提醒:这样保护颈椎才正确
什么是幸存者偏差丨深度笔记
高情商的人,这样赞美别人
守护孕期口腔健康,为每颗牙“建档”
日本职场什么样子?中国人进去会咋样?
古代驯养狗的初衷是什么?
甲状腺癌术后康复指南:从住院到出院后的全方位护理建议
趋肤效应的通俗理解与集肤深度计算
使用 OpenCV 进行图像轮廓分析
产品经理如何翻译需求
福建闽菜与福州菜美食特辑:佛跳墙、荔枝肉、黄鱼、肉燕、福州鱼丸、捞化都是必吃
二十四节气|雨水三候:春风化雨,生发万物
2024年6类货车司机意外险怎么买?6类货车司机意外险要多少钱一年?
看《花样年华》的一些笔记
平安时代的华丽篇章:《致光之君》揭秘《源氏物语》背后的故事!
猪肉选购指南:15种部位肉质特点与烹饪建议
援灾物资迅速响应,中国企业在行动