Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
-
from diffusers import
|
| 4 |
|
| 5 |
-
model_id = "
|
| 6 |
|
| 7 |
-
pipe =
|
| 8 |
model_id,
|
| 9 |
torch_dtype=torch.float32
|
| 10 |
)
|
|
@@ -14,19 +14,23 @@ pipe.to("cpu")
|
|
| 14 |
def generate(prompt):
|
| 15 |
image = pipe(
|
| 16 |
prompt,
|
| 17 |
-
num_inference_steps=1,
|
| 18 |
-
guidance_scale=0.0,
|
| 19 |
width=512,
|
| 20 |
-
height=512
|
|
|
|
|
|
|
| 21 |
).images[0]
|
| 22 |
|
| 23 |
return image
|
| 24 |
|
| 25 |
-
|
| 26 |
fn=generate,
|
| 27 |
-
inputs=gr.Textbox(
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from diffusers import StableDiffusionPipeline
|
| 4 |
|
| 5 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 6 |
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 8 |
model_id,
|
| 9 |
torch_dtype=torch.float32
|
| 10 |
)
|
|
|
|
| 14 |
def generate(prompt):
|
| 15 |
image = pipe(
|
| 16 |
prompt,
|
|
|
|
|
|
|
| 17 |
width=512,
|
| 18 |
+
height=512,
|
| 19 |
+
num_inference_steps=30,
|
| 20 |
+
guidance_scale=7.5
|
| 21 |
).images[0]
|
| 22 |
|
| 23 |
return image
|
| 24 |
|
| 25 |
+
app = gr.Interface(
|
| 26 |
fn=generate,
|
| 27 |
+
inputs=gr.Textbox(
|
| 28 |
+
label="Describe your image"
|
| 29 |
+
),
|
| 30 |
+
outputs=gr.Image(
|
| 31 |
+
label="Generated Image"
|
| 32 |
+
),
|
| 33 |
+
title="Dr Data Skeleton Image Generator"
|
| 34 |
)
|
| 35 |
|
| 36 |
+
app.launch()
|