Skip to content

Commit 6382663

Browse files
[Community] Experimental AnimateDiff Image to Video (open to improvements) (#6509)
* add animatediff img2vid * fix * Update examples/community/README.md Co-authored-by: Patrick von Platen <[email protected]> * fix code snippet between ip adapter face id and animatediff img2vid --------- Co-authored-by: Patrick von Platen <[email protected]>
1 parent 58b8dce commit 6382663

File tree

2 files changed

+1017
-1
lines changed

2 files changed

+1017
-1
lines changed

examples/community/README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ prompt-to-prompt | change parts of a prompt and retain image structure (see [pap
5858
| Null-Text Inversion Pipeline | Implement [Null-text Inversion for Editing Real Images using Guided Diffusion Models](https://arxiv.org/abs/2211.09794) as a pipeline. | [Null-Text Inversion](https://github.com/google/prompt-to-prompt/) | - | [Junsheng Luan](https://github.com/Junsheng121) |
5959
| Rerender A Video Pipeline | Implementation of [[SIGGRAPH Asia 2023] Rerender A Video: Zero-Shot Text-Guided Video-to-Video Translation](https://arxiv.org/abs/2306.07954) | [Rerender A Video Pipeline](#Rerender_A_Video) | - | [Yifan Zhou](https://github.com/SingleZombie) |
6060
| StyleAligned Pipeline | Implementation of [Style Aligned Image Generation via Shared Attention](https://arxiv.org/abs/2312.02133) | [StyleAligned Pipeline](#stylealigned-pipeline) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/15X2E0jFPTajUIjS0FzX50OaHsCbP2lQ0/view?usp=sharing) | [Aryan V S](https://github.com/a-r-r-o-w) |
61+
| AnimateDiff Image-To-Video Pipeline | Experimental Image-To-Video support for AnimateDiff (open to improvements) | [AnimateDiff Image To Video Pipeline](#animatediff-image-to-video-pipeline) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://drive.google.com/file/d/1TvzCDPHhfFtdcJZe4RLloAwyoLKuttWK/view?usp=sharing) | [Aryan V S](https://github.com/a-r-r-o-w) |
62+
6163
| IP Adapter FaceID Stable Diffusion | Stable Diffusion Pipeline that supports IP Adapter Face ID | [IP Adapter Face ID](#ip-adapter-face-id) | - | [Fabio Rigano](https://github.com/fabiorigano) |
6264

6365
To load a custom pipeline you just need to pass the `custom_pipeline` argument to `DiffusionPipeline`, as one of the files in `diffusers/examples/community`. Feel free to send a PR with your own pipelines, we will merge them quickly.
@@ -2990,7 +2992,7 @@ pipe = DiffusionPipeline.from_pretrained(
29902992
custom_pipeline="pipeline_animatediff_controlnet",
29912993
).to(device="cuda", dtype=torch.float16)
29922994
pipe.scheduler = DPMSolverMultistepScheduler.from_pretrained(
2993-
model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1, beta_schedule="linear",
2995+
model_id, subfolder="scheduler", beta_schedule="linear", clip_sample=False, timestep_spacing="linspace", steps_offset=1
29942996
)
29952997
pipe.enable_vae_slicing()
29962998
@@ -3409,7 +3411,32 @@ images = pipe(
34093411
pipe.disable_style_aligned()
34103412
```
34113413

3414+
### AnimateDiff Image-To-Video Pipeline
3415+
3416+
This pipeline adds experimental support for the image-to-video task using AnimateDiff. Refer to [this](https://github.com/huggingface/diffusers/pull/6328) PR for more examples and results.
3417+
3418+
```py
3419+
import torch
3420+
from diffusers import MotionAdapter, DiffusionPipeline, DDIMScheduler
3421+
from diffusers.utils import export_to_gif, load_image
3422+
3423+
adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2")
3424+
pipe = DiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V5.1_noVAE", motion_adapter=adapter, custom_pipeline="pipeline_animatediff_img2video").to("cuda")
3425+
pipe.scheduler = DDIMScheduler(beta_schedule="linear", steps_offset=1, clip_sample=False, timespace_spacing="linspace")
3426+
3427+
image = load_image("snail.png")
3428+
output = pipe(
3429+
image=image,
3430+
prompt="A snail moving on the ground",
3431+
strength=0.8,
3432+
latent_interpolation_method="slerp", # can be lerp, slerp, or your own callback
3433+
)
3434+
frames = output.frames[0]
3435+
export_to_gif(frames, "animation.gif")
3436+
```
3437+
34123438
### IP Adapter Face ID
3439+
34133440
IP Adapter FaceID is an experimental IP Adapter model that uses image embeddings generated by `insightface`, so no image encoder needs to be loaded.
34143441
You need to install `insightface` and all its requirements to use this model.
34153442
You must pass the image embedding tensor as `image_embeds` to the StableDiffusionPipeline instead of `ip_adapter_image`.

0 commit comments

Comments
 (0)