开源视频生成 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视频生成,从当前效果来看,依然任重道远!
热门推荐
长期吃苹果到底防癌还是伤身?提醒:保护免疫力,建议你这样做
保尔·柯察金的经典语录:激励当代人的精神力量
羊肉是心血管疾病的“祸根”?医生:这3类人千万别多吃
豆漿功效與禁忌|懷孕可以喝豆漿嗎?含豐富蛋白質的豆漿長期飲用會有副作用嗎?
奇幻电影《崂山道士》:特效虽炫但剧情引争议
《崂山道士》:一部融合戏曲与水墨的动画经典
太清宫:从千年道观到网红打卡地
《崂山道士》:一部动画,一堂人生课
张伟丽的全球格斗影响力与中国武术的现代化
异地恋如何通过沟通建立信任?
InVEST模型参数设置秘籍:专家推荐的最佳实践
裁员后如何重整旗鼓:十大建议助你再出发
InVEST模型在生态保护中的应用:以白老师的研究实践为例
三星电子裁员背后:全球经济放缓下的企业转型之路
年底裁员潮来袭:如何保护你的合法权益?
裁员潮下的企业文化重塑:从透明沟通到人文关怀
七九天养肝护肝全攻略:从生活到饮食的全方位调养
七九天来了!吃糕赏花灯,你准备好了吗?
【美丽河湖·优秀案例】湛江:湖光岩湖——最典型、保存最完整的玛珥湖
中国最美的6个“6A”景区,70岁之前一定要去一次!
广东湛江赤坎民国风情街:百年沧桑里的历史印记
冬日暖阳 来湛江海上“浪一浪”
王重阳与全真七子:道教文化的传承与创新
创新引领中医器械高质量发展
重庆大学&暨大新发现:纳米硒对抗心肌梗死有奇效!
呼伦贝尔春节秘籍:民俗+美食,年味儿拉满
经典电影《柳堡的故事》与插曲《九九艳阳天》
昆仑决付费点播:格斗迷的新宠?
朱自清散文语言艺术:清新与诗意的完美融合
朱自清散文中的诗意之美