Views
No views yet
1import torch
2from diffusers import AnimateDiffPipeline, LCMScheduler, MotionAdapter
3from diffusers.utils import export_to_gif
4
5adapter = MotionAdapter.from_pretrained("wangfuyun/AnimateLCM", torch_dtype=torch.float16)
6pipe = AnimateDiffPipeline.from_pretrained("emilianJR/epiCRealism", motion_adapter=adapter, torch_dtype=torch.float16)
7pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config, beta_schedule="linear")
8
9pipe.load_lora_weights("wangfuyun/AnimateLCM", weight_name="AnimateLCM_sd15_t2v_lora.safetensors", adapter_name="lcm-lora")
10pipe.set_adapters(["lcm-lora"], [0.8])
11
12pipe.enable_vae_slicing()
13pipe.enable_model_cpu_offload()
14
15output = 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)
23frames = output.frames[0]
24export_to_gif(frames, "animatelcm.gif")