Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,22 @@
|
|
1 |
from diffusers import DiffusionPipeline, LCMScheduler
|
|
|
2 |
import gradio as gr
|
3 |
-
import torch
|
4 |
|
5 |
|
6 |
-
|
7 |
-
|
8 |
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
9 |
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
|
10 |
-
pipe = pipe.to("cpu")
|
11 |
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def generate_images(prompt, batch_size):
|
14 |
images = []
|
15 |
for _ in range(batch_size):
|
16 |
-
results =
|
17 |
-
prompt=prompt,
|
18 |
-
num_inference_steps=4,
|
19 |
-
guidance_scale=0.0,
|
20 |
-
)
|
21 |
images.append(results.images[0])
|
22 |
return images
|
23 |
|
@@ -28,7 +27,7 @@ iface = gr.Interface(
|
|
28 |
gr.Slider(label="Number of Images", minimum=1, maximum=12, step=1, value=1)
|
29 |
],
|
30 |
outputs=gr.Gallery(label="Generated Images"),
|
31 |
-
title="SuperFast SDXL
|
32 |
)
|
33 |
|
34 |
-
iface.launch()
|
|
|
1 |
from diffusers import DiffusionPipeline, LCMScheduler
|
2 |
+
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(prompt)
|
|
|
|
|
|
|
|
|
20 |
images.append(results.images[0])
|
21 |
return images
|
22 |
|
|
|
27 |
gr.Slider(label="Number of Images", minimum=1, maximum=12, step=1, value=1)
|
28 |
],
|
29 |
outputs=gr.Gallery(label="Generated Images"),
|
30 |
+
title="SuperFast SDXL Generation on CPU"
|
31 |
)
|
32 |
|
33 |
+
iface.launch(debug=True)
|