Spaces:
Runtime error
Runtime error
File size: 1,259 Bytes
97baa3c 666ddb4 97baa3c 041beae 666ddb4 041beae 97baa3c 666ddb4 041beae 666ddb4 97baa3c 041beae 97baa3c 041beae 97baa3c 041beae 97baa3c 041beae 97baa3c 041beae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from diffusers import DiffusionPipeline, LCMScheduler
from optimum.intel import OVStableDiffusionXLPipeline
import gradio as gr
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipe = DiffusionPipeline.from_pretrained(model_id)
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
pipeline = OVStableDiffusionXLPipeline.from_pretrained(
pipe,
export=True
)
def generate_images(prompt, batch_size, num_inference_steps, guidance_scale):
images = []
for _ in range(batch_size):
results = pipeline(
prompt=prompt,
num_inference_steps=num_inference_steps,
guidance_scale=guidance_scale
)
images.append(results.images[0])
return images
iface = gr.Interface(
fn=generate_images,
inputs=[
gr.Textbox(label="Prompt"),
gr.Slider(label="Batch Size", minimum=1, maximum=12, step=1, value=1),
gr.Slider(label="Num Inference Steps", minimum=1, maximum=6, step=1, value=4),
gr.Slider(label="Guidance Scale", minimum=0.0, maximum=3, step=0.1, value=1.4)
],
outputs=gr.Gallery(label="Generated Images"),
title="Fast SDXL Generation on CPU"
)
iface.launch() |