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