Views
No views yet

StableDiffusionPipeline from diffusers library directly. It can allow reducing the number of required sampling steps to 2-4 steps.1from diffusers import StableDiffusionPipeline, LCMScheduler
2
3adapter_id = "jasperai/flash-sd"
4
5pipe = StableDiffusionPipeline.from_pretrained(
6 "runwayml/stable-diffusion-v1-5",
7 use_safetensors=True,
8)
9
10pipe.scheduler = LCMScheduler.from_pretrained(
11 "runwayml/stable-diffusion-v1-5",
12 subfolder="scheduler",
13 timestep_spacing="trailing",
14)
15pipe.to("cuda")
16
17# Fuse and load LoRA weights
18pipe.load_lora_weights(adapter_id)
19pipe.fuse_lora()
20
21prompt = "A raccoon reading a book in a lush forest."
22
23image = pipe(prompt, num_inference_steps=4, guidance_scale=0).images[0]
1@misc{chadebec2024flash,
2 title={Flash Diffusion: Accelerating Any Conditional Diffusion Model for Few Steps Image Generation},
3 author={Clement Chadebec and Onur Tasar and Eyal Benaroche and Benjamin Aubin},
4 year={2024},
5 eprint={2406.02347},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}