patrickvonplaten dn6 HF staff commited on
Commit
6167b88
1 Parent(s): 640522d

Create README.md (#2)

Browse files

- Create README.md (504374388860e52e206813f44f1ab60a3814152a)


Co-authored-by: Dhruv Nair <dn6@users.noreply.huggingface.co>

Files changed (1) hide show
  1. README.md +65 -0
README.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: diffusers
3
+ pipeline_tag: text-to-video
4
+ ---
5
+
6
+ AnimateDiff is a method that allows you to create videos using pre-existing Stable Diffusion Text to Image models.
7
+
8
+ It achieves this by inserting motion module layers into a frozen text to image model and training it on video clips to extract a motion prior.
9
+ These motion modules are applied after the ResNet and Attention blocks in the Stable Diffusion UNet. Their purpose is to introduce coherent motion across image frames. To support these modules we introduce the concepts of a MotionAdapter and UNetMotionModel. These serve as a convenient way to use these motion modules with existing Stable Diffusion models.
10
+
11
+ <table>
12
+ <tr>
13
+ <td><center>
14
+ masterpiece, bestquality, sunset.
15
+ <br>
16
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/animatediff-realistic-doc.gif"
17
+ alt="masterpiece, bestquality, sunset"
18
+ style="width: 300px;" />
19
+ </center></td>
20
+ </tr>
21
+ </table>
22
+
23
+ The following example demonstrates how you can utilize the motion modules with an existing Stable Diffusion text to image model.
24
+
25
+ ```python
26
+ import torch
27
+ from diffusers import MotionAdapter, AnimateDiffPipeline, DDIMScheduler
28
+ from diffusers.utils import export_to_gif
29
+
30
+ # Load the motion adapter
31
+ adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2")
32
+ # load SD 1.5 based finetuned model
33
+ model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
34
+ pipe = AnimateDiffPipeline.from_pretrained(model_id, motion_adapter=adapter)
35
+ scheduler = DDIMScheduler.from_pretrained(
36
+ model_id, subfolder="scheduler", clip_sample=False, timestep_spacing="linspace", steps_offset=1
37
+ )
38
+ pipe.scheduler = scheduler
39
+
40
+ # enable memory savings
41
+ pipe.enable_vae_slicing()
42
+ pipe.enable_model_cpu_offload()
43
+
44
+ output = pipe(
45
+ prompt=(
46
+ "masterpiece, bestquality, highlydetailed, ultradetailed, sunset, "
47
+ "orange sky, warm lighting, fishing boats, ocean waves seagulls, "
48
+ "rippling water, wharf, silhouette, serene atmosphere, dusk, evening glow, "
49
+ "golden hour, coastal landscape, seaside scenery"
50
+ ),
51
+ negative_prompt="bad quality, worse quality",
52
+ num_frames=16,
53
+ guidance_scale=7.5,
54
+ num_inference_steps=25,
55
+ generator=torch.Generator("cpu").manual_seed(42),
56
+ )
57
+ frames = output.frames[0]
58
+ export_to_gif(frames, "animation.gif")
59
+ ```
60
+
61
+ <Tip>
62
+
63
+ AnimateDiff tends to work better with finetuned Stable Diffusion models. If you plan on using a scheduler that can clip samples, make sure to disable it by setting `clip_sample=False` in the scheduler as this can also have an adverse effect on generated samples.
64
+
65
+ </Tip>