Views
No views yet
stable-diffusion-xl-base-1.0 that allows
to reduce the number of inference steps to only between 2 - 8 steps.peft, accelerate and transformers.
audio dataset from the Hugging Face Hub:1pip install --upgrade pip
2pip install --upgrade diffusers transformers accelerate peftstabilityai/stable-diffusion-xl-base-1.0. Next, the scheduler needs to be changed to LCMScheduler and we can reduce the number of inference steps to just 2 to 8 steps.
Please make sure to either disable guidance_scale or use values between 1.0 and 2.0.1from diffusers import UNet2DConditionModel, DiffusionPipeline, LCMScheduler
2import torch
3
4unet = UNet2DConditionModel.from_pretrained("latent-consistency/lcm-sdxl", torch_dtype=torch.float16, variant="fp16")
5pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", unet=unet, torch_dtype=torch.float16, variant="fp16")
6
7pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
8pipe.to("cuda")
9
10prompt = "a close-up picture of an old man standing in the rain"
11
12image = pipe(prompt, num_inference_steps=4, guidance_scale=8.0).images[0]