dn6 HF staff commited on
Commit
6b8d28e
1 Parent(s): 449d899

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +70 -0
README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-3")
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,
37
+ subfolder="scheduler",
38
+ clip_sample=False,
39
+ beta_schedule="linear",
40
+ timestep_spacing="linspace",
41
+ steps_offset=1
42
+ )
43
+ pipe.scheduler = scheduler
44
+
45
+ # enable memory savings
46
+ pipe.enable_vae_slicing()
47
+ pipe.enable_model_cpu_offload()
48
+
49
+ output = pipe(
50
+ prompt=(
51
+ "masterpiece, bestquality, highlydetailed, ultradetailed, sunset, "
52
+ "orange sky, warm lighting, fishing boats, ocean waves seagulls, "
53
+ "rippling water, wharf, silhouette, serene atmosphere, dusk, evening glow, "
54
+ "golden hour, coastal landscape, seaside scenery"
55
+ ),
56
+ negative_prompt="bad quality, worse quality",
57
+ num_frames=16,
58
+ guidance_scale=7.5,
59
+ num_inference_steps=25,
60
+ generator=torch.Generator("cpu").manual_seed(42),
61
+ )
62
+ frames = output.frames[0]
63
+ export_to_gif(frames, "animation.gif")
64
+ ```
65
+
66
+ <Tip>
67
+
68
+ 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.
69
+
70
+ </Tip>