🚀 Allegro - 文本到视频生成模型
Allegro 是一款开源的文本到视频生成模型,能够生成多种类型的高质量视频内容。它具有参数小、效率高的特点,支持多种精度,为视频创作提供了强大的工具。
示例画廊 · GitHub · 博客 · 论文 · Discord · 加入等待列表 (在 Discord 上试用!)
🖼️ 示例画廊

更多演示和对应的提示词,请查看 [Allegro 示例画廊](https://rhymes.ai/allegro_gallery)。
✨ 主要特性
- 开源共享:社区可获取完整的 模型权重 和 代码,采用 Apache 2.0 许可证!
- 内容多样:能够生成广泛的内容,从人物和动物特写镜头到各种动态场景。
- 高质量输出:以 15 FPS 生成 6 秒的详细视频,分辨率为 720x1280,可使用 EMA-VFI 插值到 30 FPS。
- 小巧高效:采用 1.75 亿参数的 VideoVAE 和 28 亿参数的 VideoDiT 模型。支持多种精度(FP32、BF16、FP16),在 BF16 模式下使用 CPU 卸载时,仅需 9.3 GB 的 GPU 内存。上下文长度为 79.2K,相当于 88 帧。
ℹ️ 模型信息
属性 |
详情 |
模型名称 |
Allegro |
模型描述 |
文本到视频生成模型 |
下载地址 |
Hugging Face |
模型参数 |
VAE: 1.75 亿;DiT: 28 亿 |
推理精度 |
VAE: FP32/TF32/BF16/FP16(FP32/TF32 最佳);DiT/T5: BF16/FP32/TF32 |
上下文长度 |
79.2K |
分辨率 |
720 x 1280 |
帧数 |
88 |
视频长度 |
6 秒 @ 15 FPS |
单 GPU 内存使用量 |
9.3G BF16(使用 CPU 卸载) |
🚀 快速开始
1. 安装必要的依赖项
- 确保 Python >= 3.10,PyTorch >= 2.4,CUDA >= 12.4。
- 建议使用 Anaconda 创建一个新的环境(Python >= 3.10)
conda create -n rllegro python=3.10 -y
来运行以下示例。
- 运行
pip install git+https://github.com/huggingface/diffusers.git torch==2.4.1 transformers==4.40.1 accelerate sentencepiece imageio imageio-ffmpeg beautifulsoup4
2. 运行推理
import torch
from diffusers import AutoencoderKLAllegro, AllegroPipeline
from diffusers.utils import export_to_video
vae = AutoencoderKLAllegro.from_pretrained("rhymes-ai/Allegro", subfolder="vae", torch_dtype=torch.float32)
pipe = AllegroPipeline.from_pretrained(
"rhymes-ai/Allegro", vae=vae, torch_dtype=torch.bfloat16
)
pipe.to("cuda")
pipe.vae.enable_tiling()
prompt = "A seaside harbor with bright sunlight and sparkling seawater, with many boats in the water. From an aerial view, the boats vary in size and color, some moving and some stationary. Fishing boats in the water suggest that this location might be a popular spot for docking fishing boats."
positive_prompt = """
(masterpiece), (best quality), (ultra-detailed), (unwatermarked),
{}
emotional, harmonious, vignette, 4k epic detailed, shot on kodak, 35mm photo,
sharp focus, high budget, cinemascope, moody, epic, gorgeous
"""
negative_prompt = """
nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality,
low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry.
"""
prompt = prompt.format(prompt.lower().strip())
video = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=7.5, max_sequence_length=512, num_inference_steps=100, generator = torch.Generator(device="cuda:0").manual_seed(42)).frames[0]
export_to_video(video, "output.mp4", fps=15)
使用 pipe.enable_sequential_cpu_offload()
将模型卸载到 CPU 以降低 GPU 内存成本(约 9.3G,未启用 CPU 卸载时为 27.5G),但推理时间会显著增加。
3. (可选)将视频插值到 30 FPS
建议使用 EMA-VFI 将视频从 15 FPS 插值到 30 FPS。为获得更好的视觉质量,请使用 imageio 保存视频。
4. 更快的推理
如需更快的推理,如上下文并行、PAB 等,请参考我们的 GitHub 仓库。
📄 许可证
本仓库采用 Apache 2.0 许可证发布。