🚀 AnimateDiff-Lightning
AnimateDiff-Lightning是一款閃電般快速的文本到視頻生成模型,它生成視頻的速度比原始的AnimateDiff快十倍以上。本模型作為研究成果發佈,更多信息請參考我們的研究論文:AnimateDiff-Lightning: Cross-Model Diffusion Distillation。
🚀 快速開始
你可以通過以下方式快速體驗AnimateDiff-Lightning:
- 試用我們的文本到視頻生成演示。
- 按照下文的使用示例進行操作。
✨ 主要特性
- 高速生成:相比原始的AnimateDiff,生成視頻的速度快十倍以上。
- 多步選擇:提供1步、2步、4步和8步蒸餾模型的檢查點。
- 高質量輸出:2步、4步和8步模型的生成質量出色。
- 廣泛適配:與多種風格化基礎模型兼容,適用於不同場景。
📦 安裝指南
本模型的使用依賴於一些Python庫,你可以通過以下命令安裝:
pip install diffusers torch safetensors huggingface_hub
💻 使用示例
基礎用法
以下是使用Diffusers庫調用AnimateDiff-Lightning的示例代碼:
import torch
from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
from diffusers.utils import export_to_gif
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
device = "cuda"
dtype = torch.float16
step = 4
repo = "ByteDance/AnimateDiff-Lightning"
ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
base = "emilianJR/epiCRealism"
adapter = MotionAdapter().to(device, dtype)
adapter.load_state_dict(load_file(hf_hub_download(repo ,ckpt), device=device))
pipe = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, torch_dtype=dtype).to(device)
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
output = pipe(prompt="A girl smiling", guidance_scale=1.0, num_inference_steps=step)
export_to_gif(output.frames[0], "animation.gif")
ComfyUI使用方法
- 下載animatediff_lightning_workflow.json並在ComfyUI中導入。
- 安裝節點。你可以手動安裝或使用ComfyUI-Manager:
- 下載你喜歡的基礎模型檢查點並將其放在
/models/checkpoints/
目錄下。
- 下載AnimateDiff-Lightning檢查點
animatediff_lightning_Nstep_comfyui.safetensors
並將其放在/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/
目錄下。

視頻到視頻生成
AnimateDiff-Lightning在視頻到視頻生成方面表現出色。以下是使用ControlNet的簡單ComfyUI工作流程:
- 下載animatediff_lightning_v2v_openpose_workflow.json並在ComfyUI中導入。
- 安裝節點。你可以手動安裝或使用ComfyUI-Manager:
- 下載你喜歡的基礎模型檢查點並將其放在
/models/checkpoints/
目錄下。
- 下載AnimateDiff-Lightning檢查點
animatediff_lightning_Nstep_comfyui.safetensors
並將其放在/custom_nodes/ComfyUI-AnimateDiff-Evolved/models/
目錄下。
- 下載ControlNet OpenPose
control_v11p_sd15_openpose.pth
檢查點到/models/controlnet/
目錄下。
- 上傳你的視頻並運行管道。
額外注意事項
- 視頻不應過長或分辨率過高。我們使用576x1024、8秒、30fps的視頻進行測試。
- 設置幀率以匹配輸入視頻,這樣可以使音頻與輸出視頻匹配。
- DWPose在首次運行時會自行下載檢查點。
- DWPose可能會在UI中卡住,但管道實際上仍在後臺運行。請檢查ComfyUI日誌和輸出文件夾。

📚 詳細文檔
推薦基礎模型
AnimateDiff-Lightning與風格化基礎模型配合使用時效果最佳。我們推薦使用以下基礎模型:
寫實風格
動漫與卡通風格
使用建議
- 嘗試不同的設置。我們發現2步模型使用3次推理步驟可以產生很好的效果。
- 某些基礎模型與CFG配合使用效果更好。
- 推薦使用Motion LoRAs,它們可以產生更強的運動效果。我們使用強度為0.7~0.8的Motion LoRAs以避免水印。
📄 許可證
本項目採用creativeml-openrail-m
許可證。
🔖 引用
如果您使用了本項目的成果,請引用以下論文:
@misc{lin2024animatedifflightning,
title={AnimateDiff-Lightning: Cross-Model Diffusion Distillation},
author={Shanchuan Lin and Xiao Yang},
year={2024},
eprint={2403.12706},
archivePrefix={arXiv},
primaryClass={cs.CV}
}