开源视频生成 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视频生成,从当前效果来看,依然任重道远!
热门推荐
150 多条朗朗上口的餐车标语以及如何选择标语
儒家思想:从孔子到现代社会的智慧传承
有效的负面信息处理机制包含8个关键环节
索尼电视无法开机?8个方法帮你快速诊断和解决!
上海智元新创获新专利:革新机器人关节模组,助力未来智能制造
探索之旅:郑州至重庆沿线必访的自然与文化景观
短整数在数据库如何表达
C语言如何使用短整型
解读:工业机器人行业未来发展方向和重点任务
泗水地瓜:从特产到年产值49亿的富民产业
揭秘:古今中外的牙齿清洁方式
毛笔书法入门楷书字帖教程
清华提出时间序列大模型:面向通用时序分析的生成式Transformer
信号增强小功能:轻松提升信号质量,满足您的需求!
《尼尔:机械纪元 Ver 1.1a》:虚无与希望交织的机械哲学
家里剩下的香灰先别扔,往门口撒一把,妙用无穷,真不是迷信
华为高端手机大降价
天机泄露:古代中国如何用星辰预测未来
国台酒的智能酿造之路:从经验到数据的转型升级
头皮出油多掉发怎么治疗
哪些战斗机拥有最强大的发动机:从俄罗斯的米格-31到美国的F-35
花卉春雨的寓意及象征是什么?春雨对花卉生长的影响有哪些?
为什么“自”字最初的意思是“鼻子” | 汉字里的文化
为什么"自"字最初的意思是"鼻子" | 汉字里的文化
D罩杯内衣尺码详解与选购指南
杨廷和:明朝忠诚的政治家与改革者
小白投资理财 - 看懂 PE Ratio 市盈率
中国科技股资产重估进行时,硬科技龙头显现增长潜力
音频文件在计算机中是怎么存储的?逻辑结构是怎么样的?
香薰竟然能治愈打工人的疲惫!