AnimateDiff

AnimateDiff

为文本到图像模型赋予动画生成能力的即插即用模块

AnimateDiff是一个即插即用模块,可将文本到图像模型转变为动画生成器,无需额外训练。通过学习可迁移的运动先验,它适用于Stable Diffusion系列的多种变体。该项目支持使用社区模型生成动画、MotionLoRA控制以及SparseCtrl RGB和草图控制等功能。AnimateDiff增强了文本到视频模型的控制能力,能生成高质量动画。

AnimateDiff文本生成动画稳定扩散运动模块社区模型Github开源项目

AnimateDiff

这个仓库是AnimateDiff [ICLR2024 Spotlight]的官方实现。 它是一个即插即用的模块,可以将大多数社区文本到图像模型转变为动画生成器,无需额外训练。

AnimateDiff:无需特定调整即可为个性化文本到图像扩散模型添加动画效果 </br> 郭宇伟杨策元✝饶安逸梁正阳王耀辉乔宇Maneesh Agrawala林达华戴博 (✝通讯作者)
arXiv 项目主页 在OpenXLab中打开 Hugging Face Spaces

注意: main分支适用于Stable Diffusion V1.5;对于Stable Diffusion XL,请参考sdxl-beta分支。

快速演示

更多结果可以在画廊中找到。 其中一些是由社区贡献的。

<table class="center"> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/7b0a76cb-47fb-4925-99d8-592788e6ac2e.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/d61c0353-1ca1-43cc-a534-fdbdeb29a12d.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/afd080be-8e1b-4c90-8621-dc3e4162b003.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/6bf75623-0aec-4199-acbe-70c40c78cbab.gif"></td> </tr> </table> <p style="margin-left: 2em; margin-top: -1em">模型:<a href="https://civitai.com/models/30240/toonyou">ToonYou</a></p> <table> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/c99a19ac-a959-4cc6-be89-81c571535252.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/a8b0fccc-6c6b-4e5f-8b01-e8e836f41fec.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/00e4695e-f5a3-445b-92b4-71f830589e62.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/89564a94-316d-4a84-b2f6-1922f39ed0b6.gif"></td> </tr> </table> <p style="margin-left: 2em; margin-top: -1em">模型:<a href="https://civitai.com/models/4201/realistic-vision-v20">Realistic Vision V2.0</a></p>

快速开始

注意: AnimateDiff 也得到了 Diffusers 的官方支持。 访问 AnimateDiff Diffusers 教程 获取更多详情。 以下说明适用于使用本仓库

注意: 对于所有脚本,检查点的下载将自动处理,因此首次执行时脚本运行可能需要更长时间。

1. 设置仓库和环境

git clone https://github.com/guoyww/AnimateDiff.git
cd AnimateDiff

pip install -r requirements.txt

2. 启动采样脚本!

生成的样本可以在 samples/ 文件夹中找到。

2.1 使用社区模型生成动画

python -m scripts.animate --config configs/prompts/1_animate/1_1_animate_RealisticVision.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_2_animate_FilmVelvia.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_3_animate_ToonYou.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_4_animate_MajicMix.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_5_animate_RcnzCartoon.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_6_animate_Lyriel.yaml
python -m scripts.animate --config configs/prompts/1_animate/1_7_animate_Tusun.yaml

2.2 使用 MotionLoRA 控制生成动画

python -m scripts.animate --config configs/prompts/2_motionlora/2_motionlora_RealisticVision.yaml

2.3 使用 SparseCtrl RGB 和草图进行更多控制

python -m scripts.animate --config configs/prompts/3_sparsectrl/3_1_sparsectrl_i2v.yaml
python -m scripts.animate --config configs/prompts/3_sparsectrl/3_2_sparsectrl_rgb_RealisticVision.yaml
python -m scripts.animate --config configs/prompts/3_sparsectrl/3_3_sparsectrl_sketch_RealisticVision.yaml

2.4 Gradio 应用

我们创建了一个 Gradio 演示以使 AnimateDiff 更易于使用。 默认情况下,演示将在 localhost:7860 运行。

python -u app.py
<img src="https://yellow-cdn.veclightyear.com/835a84d5/f012ae23-5c90-4316-bbcb-1641fbc8e69f.jpg" style="width: 75%">

技术说明

<details close> <summary>技术说明</summary>

AnimateDiff

AnimateDiff 旨在学习可转移的运动先验,以应用于 Stable Diffusion 系列的其他变体。 为此,我们设计了以下由三个阶段组成的训练流程。

<img src="https://yellow-cdn.veclightyear.com/835a84d5/9e1d1adf-ae79-47eb-9e9a-68fc0896db14.png" style="width:100%">
  • 1. 缓解负面影响阶段,我们训练领域适配器,例如 v3_sd15_adapter.ckpt,以适应训练数据集中的有缺陷的视觉伪影(如水印)。 这也有利于运动和空间外观的解耦学习。 默认情况下,适配器可在推理时移除。它也可以集成到模型中,其效果可通过 lora 缩放器调整。

  • 2. 学习运动先验阶段,我们训练运动模块,例如 v3_sd15_mm.ckpt,以从视频中学习真实世界的运动模式。

  • 3.(可选)适应新模式阶段,我们训练MotionLoRA,例如 v2_lora_ZoomIn.ckpt,以高效地使运动模块适应特定的运动模式(相机缩放、旋转等)。

SparseCtrl

SparseCtrl 旨在通过采用一些稀疏输入(如少量 RGB 图像或草图输入)为文本到视频模型增加更多控制。 其技术细节可在以下论文中找到:

SparseCtrl: 为文本到视频扩散模型添加稀疏控制
郭宇伟杨策元✝饶安逸Maneesh Agrawala林达华戴博 (✝通讯作者)
arXiv 项目主页

模型版本

AnimateDiff v3 和 SparseCtrl(2023.12)

在这个版本中,我们使用领域适配器 LoRA进行图像模型微调,这在推理时提供了更多灵活性。 我们还实现了两个(RGB 图像/涂鸦)SparseCtrl 编码器,可以接受任意数量的条件图来控制动画内容。

局限性

  1. 可以注意到轻微的闪烁;
  2. 为了保持与社区模型的兼容性,没有针对通用 T2V 进行特定优化,导致在这种设置下视觉质量有限;
  3. (风格对齐)对于图像动画/插值等用途,建议使用由同一社区模型生成的图像。

演示

<table class="center"> <tr style="line-height: 0"> <td width=25% style="border: none; text-align: center">输入(由 RealisticVision 生成)</td> <td width=25% style="border: none; text-align: center">动画</td> <td width=25% style="border: none; text-align: center">输入</td> <td width=25% style="border: none; text-align: center">动画</td> </tr> <tr> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/7b6fdae9-44b5-42de-852c-2407e404ab90.png" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/a59571d5-eaa5-4e5d-86be-1093b1257509.gif" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/9a7bd7c7-2209-44a6-893f-d7fd681cf148.png" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/bfd00d0f-c5b6-4fd4-863b-56e042883b52.gif" style="width:100%"></td> </tr> </table> <table class="center"> <tr style="line-height: 0"> <td width=25% style="border: none; text-align: center">输入涂鸦</td> <td width=25% style="border: none; text-align: center">输出</td> <td width=25% style="border: none; text-align: center">输入涂鸦</td> <td width=25% style="border: none; text-align: center">输出</td> </tr> <tr> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/4e1fe8b5-ed1d-4c6f-8cf8-b47882f1f1d9.png" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/5c7df530-b97e-48b3-96fd-2d651d2db968.gif" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/c77d8ee9-1b4f-4c4e-964d-928a54c7c0db.png" style="width:100%"></td> <td width=25% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/8defbcfa-0d15-41a4-8369-521cc1591bc5.gif" style="width:100%"></td> </tr> </table>

AnimateDiff SDXL-Beta (2023.11)

发布了SDXL上的运动模块(测试版),可在Google DriveHuggingFaceCivitAI获取。可以生成高分辨率视频(即1024x1024x16帧,具有不同的宽高比),无论是否使用个性化模型。推理通常需要约13GB显存和调整后的超参数(如采样步数),具体取决于所选的个性化模型。 有关推理的更多详细信息,请查看sdxl分支。

<details close> <summary>AnimateDiff SDXL-Beta 模型库</summary>
名称HuggingFace类型存储空间
mm_sdxl_v10_beta.ckpt链接运动模块950 MB
</details>

演示

<table class="center"> <tr style="line-height: 0"> <td width=52% style="border: none; text-align: center">原始SDXL</td> <td width=30% style="border: none; text-align: center">社区SDXL</td> <td width=18% style="border: none; text-align: center">社区SDXL</td> </tr> <tr> <td width=52% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/f00889c2-efb1-49a0-842e-37fdb387b406.gif" style="width:100%"></td> <td width=30% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/40484647-f40b-4244-9785-bd3d4b9bb106.gif" style="width:100%"></td> <td width=18% style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/65f2ab9c-beed-45ea-9005-8f5d2fbec130.gif" style="width:100%"></td> </tr> </table>

AnimateDiff v2 (2023.09)

在这个版本中,运动模块mm_sd_v15_v2.ckptGoogle DriveHuggingFaceCivitAI)是在更大的分辨率和批次大小上训练的。 我们发现,规模化训练显著提高了运动质量和多样性。 我们还支持八种基本相机动作的MotionLoRA。 每个MotionLoRA检查点仅占用77 MB存储空间,可在Google DriveHuggingFaceCivitAI获取。

<details close> <summary>AnimateDiff v2 模型库</summary> | 名称 | HuggingFace | 类型 | 参数 | 存储 | | - | - | - | - | - | | `mm_sd_v15_v2.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/mm_sd_v15_v2.ckpt) | 运动模块 | 453 M | 1.7 GB | | `v2_lora_ZoomIn.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_ZoomIn.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_ZoomOut.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_ZoomOut.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_PanLeft.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_PanLeft.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_PanRight.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_PanRight.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_TiltUp.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_TiltUp.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_TiltDown.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_TiltDown.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_RollingClockwise.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_RollingClockwise.ckpt) | MotionLoRA | 19 M | 74 MB | | `v2_lora_RollingAnticlockwise.ckpt` | [链接](https://huggingface.co/guoyww/animatediff/blob/main/v2_lora_RollingAnticlockwise.ckpt) | MotionLoRA | 19 M | 74 MB |

演示(MotionLoRA)

<table class="center"> <tr style="line-height: 0"> <td colspan="2" style="border: none; text-align: center">放大</td> <td colspan="2" style="border: none; text-align: center">缩小</td> <td colspan="2" style="border: none; text-align: center">向左平移</td> <td colspan="2" style="border: none; text-align: center">向右平移</td> </tr> <tr> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/443b953a-f670-4935-945a-d63d64119241.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/cf6d139c-9772-4c31-808c-cbd7454d7df9.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/f493b3d0-fbc1-48c5-bb28-96f3bf3a3aa2.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/3ed2dc06-0dd1-42ce-843a-9be7ce74d962.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/c58e8dd2-7ffc-4c54-9aed-5dc0b674c1f3.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/8b97d621-0fc7-4901-8b94-c90179d1d78c.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/b94ed533-f980-46aa-958e-edae209ba857.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/2b844762-4c6a-424d-a278-18a04e1d53c5.gif"></td> </tr> <tr style="line-height: 0"> <td colspan="2" style="border: none; text-align: center">向上倾斜</td> <td colspan="2" style="border: none; text-align: center">向下倾斜</td> <td colspan="2" style="border: none; text-align: center">逆时针旋转</td> <td colspan="2" style="border: none; text-align: center">顺时针旋转</td> </tr> <tr> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/bb8a60d7-6959-45cb-b61c-223400fbe737.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/74b58a88-e18f-458d-8a52-745c3b768d43.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/54e71584-05db-48d1-9fcd-e835b8502f54.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/08d86ef5-4813-4968-87d6-1d5ad4709c70.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/aad3a51c-34a2-48e5-8add-9a50ff8a1ddb.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/b161418d-240c-408c-8cf7-3cbdfab8ee8a.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/20b486d3-81dd-4e44-b6f4-4bdb1b84eaf5.gif"></td> <td style="border: none"><img src="https://yellow-cdn.veclightyear.com/835a84d5/5ab53db7-bf68-4bd1-9a3a-0ff43c100cd5.gif"></td> </tr> </table>

演示(改进的运动)

以下是mm_sd_v15.ckpt(左)和改进的mm_sd_v15_v2.ckpt(右)之间的对比。

<table class="center"> <tr> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/8bb3baf0-05ad-4812-b92e-5b8de32e2284.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/6997932c-3c2a-4800-b77f-64f9e2419dd2.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/1646d39d-bc4c-482c-947f-66efaaf31551.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/c87f2a41-fb88-444b-9cb1-e7a05e5753fc.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/87e30f1a-87eb-45c7-8e50-3cc7d3543358.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/1e3f6d08-aff8-4f7d-9940-57da2a20e32c.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/cda5fa1a-775c-47b7-a72c-785513a655f7.gif"></td> <td><img src="https://yellow-cdn.veclightyear.com/835a84d5/86d4251c-1b0f-4923-8912-69a5f83af1fb.gif"></td> </tr> </table>

AnimateDiff v1(2023.07)

AnimateDiff的第一个版本!

<details close> <summary>AnimateDiff v1 模型库</summary>
名称HuggingFace参数存储空间
mm_sd_v14.ckpt链接417 M1.6 GB
mm_sd_v15.ckpt链接417 M1.6 GB
</details> </details>

训练

详细信息请查看训练步骤

相关资源

Stable Diffusion WebUI的AnimateDiff:sd-webui-animatediff(由@continue-revolution开发)
ComfyUI的AnimateDiff:ComfyUI-AnimateDiff-Evolved(由@Kosinkadink开发)
Google Colab:Colab(由@camenduru提供)

免责声明

本项目仅供学术用途。 我们对用户生成的内容不承担任何责任。 另外,请注意,我们的官方网站只有https://github.com/guoyww/AnimateDiff和https://animatediff.github.io,其他所有网站均与AnimateDiff无关。

联系我们

郭宇伟:guoyw@ie.cuhk.edu.hk
杨策元:limbo0066@gmail.com
戴波:doubledaibo@gmail.com

BibTeX

@article{guo2023animatediff,
  title={AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning},
  author={Guo, Yuwei and Yang, Ceyuan and Rao, Anyi and Liang, Zhengyang and Wang, Yaohui and Qiao, Yu and Agrawala, Maneesh and Lin, Dahua and Dai, Bo},
  journal={International Conference on Learning Representations},
  year={2024}
}

@article{guo2023sparsectrl,
  title={SparseCtrl: Adding Sparse Controls to Text-to-Video Diffusion Models},
  author={Guo, Yuwei and Yang, Ceyuan and Rao, Anyi and Agrawala, Maneesh and Lin, Dahua and Dai, Bo},
  journal={arXiv preprint arXiv:2311.16933},
  year={2023}
}

致谢

代码基于Tune-a-Video构建。

编辑推荐精选

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

下拉加载更多