sanaweb commited on
Commit
b88ce93
1 Parent(s): 0e4c691

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import AnimateDiffPipeline, LCMScheduler, MotionAdapter
3
+ from diffusers.utils import export_to_gif
4
+
5
+ adapter = MotionAdapter.from_pretrained("wangfuyun/AnimateLCM", torch_dtype=torch.float16)
6
+ pipe = AnimateDiffPipeline.from_pretrained("emilianJR/epiCRealism", motion_adapter=adapter, torch_dtype=torch.float16)
7
+ pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config, beta_schedule="linear")
8
+
9
+ pipe.load_lora_weights("wangfuyun/AnimateLCM", weight_name="AnimateLCM_sd15_t2v_lora.safetensors", adapter_name="lcm-lora")
10
+ pipe.set_adapters(["lcm-lora"], [0.8])
11
+
12
+ pipe.enable_vae_slicing()
13
+ pipe.enable_model_cpu_offload()
14
+
15
+ output = pipe(
16
+ prompt="A space rocket with trails of smoke behind it launching into space from the desert, 4k, high resolution",
17
+ negative_prompt="bad quality, worse quality, low resolution",
18
+ num_frames=16,
19
+ guidance_scale=2.0,
20
+ num_inference_steps=6,
21
+ generator=torch.Generator("cpu").manual_seed(0),
22
+ )
23
+ frames = output.frames[0]
24
+ export_to_gif(frames, "animatelcm.gif")