Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
from diffusers import DiffusionPipeline, LCMScheduler
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0"
|
|
|
|
| 6 |
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
| 7 |
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def generate_images(prompt, batch_size):
|
|
@@ -13,7 +16,7 @@ def generate_images(prompt, batch_size):
|
|
| 13 |
results = pipe(
|
| 14 |
prompt=prompt,
|
| 15 |
num_inference_steps=4,
|
| 16 |
-
guidance_scale=
|
| 17 |
)
|
| 18 |
images.append(results.images[0])
|
| 19 |
return images
|
|
@@ -22,10 +25,10 @@ iface = gr.Interface(
|
|
| 22 |
fn=generate_images,
|
| 23 |
inputs=[
|
| 24 |
gr.Textbox(label="Prompt"),
|
| 25 |
-
gr.Slider(label="
|
| 26 |
],
|
| 27 |
outputs=gr.Gallery(label="Generated Images"),
|
| 28 |
-
title="SuperFast SDXL Generation
|
| 29 |
)
|
| 30 |
|
| 31 |
iface.launch()
|
|
|
|
| 1 |
from diffusers import DiffusionPipeline, LCMScheduler
|
| 2 |
import gradio as gr
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
|
| 6 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
|
| 7 |
+
torch_dtype=torch.float16)
|
| 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):
|
|
|
|
| 16 |
results = pipe(
|
| 17 |
prompt=prompt,
|
| 18 |
num_inference_steps=4,
|
| 19 |
+
guidance_scale=0.0,
|
| 20 |
)
|
| 21 |
images.append(results.images[0])
|
| 22 |
return images
|
|
|
|
| 25 |
fn=generate_images,
|
| 26 |
inputs=[
|
| 27 |
gr.Textbox(label="Prompt"),
|
| 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 Image Generation"
|
| 32 |
)
|
| 33 |
|
| 34 |
iface.launch()
|