开源视频生成 Pyramid Flow 本地部署实测
创作时间:
作者:
@小白创作中心
开源视频生成 Pyramid Flow 本地部署实测
引用
CSDN
1.
https://blog.csdn.net/u010522887/article/details/143279061
Pyramid Flow是一个开源的视频生成模型,具有参数量小、生成效果好等特点。本文将详细介绍如何在本地部署Pyramid Flow,并通过实际测试来评估其性能。
1. Pyramid Flow 简介
项目地址:https://github.com/jy0205/Pyramid-Flow
Pyramid Flow的主要亮点包括:
- 仅需2B参数,即可生成768p分辨率、24fps的10秒视频
- 支持「文本到视频」和「图像到视频」两种模式
- 采用自回归生成方式,确保视频内容的连贯性和流畅性
- 采用金字塔式的多尺度架构,生成效率更高
根据官方评测结果,除了semantic score,其他指标均优于开源方案CogVideo:
2. 在线体验
Pyramid Flow已在huggingface上线,可以直接在线体验:
https://huggingface.co/spaces/Pyramid-Flow/pyramid-flow
如果无法访问,可以查看官方的生成样例:
https://pyramid-flow.github.io/
接下来,我们将详细介绍如何在本地部署Pyramid Flow。
3. 本地部署
3.1 环境准备
首先需要准备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秒视频。
3.2 推理测试
首先加载模型:
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,至少需要19G显存,建议采用上述代码。
测试文本生成视频:
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拉开明显差距。
写在最后
AI应用大体可分为:文本、语音、图片、视频,其中语音已被硅基生物攻破。而AI视频生成,从当前效果来看,依然任重道远!
热门推荐
刘氏兄弟入籍中国,短道速滑格局大变!
《楚门的世界》:楚门走得出桃源岛,却走不出真实的“荒漠”
媒体侵犯隐私权的主要形式及法律救济途径
6部影片,带你进入虚拟世界
夫妻债务离婚如何分?一文详解债务划分与纠纷解决
告别春节假期,这份返程收心指南请收好!
贵州荔波:中国南方喀斯特·世界自然遗产地
春节职场拜年攻略:领导、同事、客户全搞定!
春节返工必学:Excel高效工作法
节后综合征来袭?这些心理调适方法超实用!
东风日产阳光Sunny燃油系统维修技巧与建议
胆固醇指数正常值是多少?过高须避吃这些食物!
黄柏的功效与作用
常用中药“三黄”
黄柏的功效与作用
《生化危机》里的鬼角色如何吓到你?
四川绵竹城遗址考古发掘取得重要成果
洞察全球汽车产业:2024年发展动态与2025年趋势预测
哈南公安检查站:科技赋能护航亚冬会
揭秘刘少昂:从匈牙利到中国,短道速滑名将的训练之道
刘少昂领衔中国队主场夺冠,短道速滑世巡赛北京站圆满收官
呼和浩特至成都自驾游全攻略:路线、景点、住宿及美食推荐
从呼和浩特到成都旅行全攻略:行程规划、必去景点与美食推荐
春节搞钱新姿势:上门喂猫&代做年夜饭
银行的信用风险管理方法有哪些?
我国植物学家在贵州发现新物种“北盘江凤仙花”
海棠叶的功效与应用
人工智能助力教育公平:技术创新推动新模式探索
国医大师:药食同源说阿胶
燕窝炖阿胶的做法窍门与大全:功效、作用全面解析