openvinotoolkit / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
290 stars 45 forks source link

[Feature Request]: Support LCM LORA #80

Open taotaow opened 1 year ago

taotaow commented 1 year ago

Is there an existing issue for this?

What would your feature do ?

lcm lora can reduce inference steps to 2~8,it's fast,even realtime! https://huggingface.co/blog/lcm_lora

Proposed workflow

from diffusers import DiffusionPipeline, LCMScheduler import torch

model_id = "wavymulder/collage-diffusion" lcm_lora_id = "latent-consistency/lcm-lora-sdv1-5"

pipe = DiffusionPipeline.from_pretrained(model_id, variant="fp16") pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config) pipe.load_lora_weights(lcm_lora_id) pipe.to(device="cuda", dtype=torch.float16)

prompt = "collage style kid sits looking at the night sky, full of stars"

generator = torch.Generator(device=pipe.device).manual_seed(1337) images = pipe( prompt=prompt, generator=generator, negative_prompt=negative_prompt, num_inference_steps=4, guidance_scale=1, ).images[0]

Additional information

No response