Views
No views yet
1import torch
2from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
3from diffusers.utils import export_to_gif
4from huggingface_hub import hf_hub_download
5from safetensors.torch import load_file
6
7device = "cuda"
8dtype = torch.float16
9
10step = 4 # Options: [1,2,4,8]
11repo = "ByteDance/AnimateDiff-Lightning"
12ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
13base = "emilianJR/epiCRealism" # Choose to your favorite base model.
14
15adapter = MotionAdapter().to(device, dtype)
16adapter.load_state_dict(load_file(hf_hub_download(repo ,ckpt), device=device))
17pipe = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, torch_dtype=dtype).to(device)
18pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
19
20output = pipe(prompt="A girl smiling", guidance_scale=1.0, num_inference_steps=step)
21export_to_gif(output.frames[0], "animation.gif")/models/checkpoints/animatediff_lightning_Nstep_comfyui.safetensors and put them under /custom_nodes/ComfyUI-AnimateDiff-Evolved/models/
/models/checkpoints/animatediff_lightning_Nstep_comfyui.safetensors and put them under /custom_nodes/ComfyUI-AnimateDiff-Evolved/models/control_v11p_sd15_openpose.pth checkpoint to /models/controlnet/
@misc{lin2024animatedifflightning,
title={AnimateDiff-Lightning: Cross-Model Diffusion Distillation},
author={Shanchuan Lin and Xiao Yang},
year={2024},
eprint={2403.12706},
archivePrefix={arXiv},
primaryClass={cs.CV}
}