🚀 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 許可證發佈。