Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
from diffusers import StableDiffusionPipeline
|
4 |
|
5 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
6 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
|
8 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
9 |
+
model_id, torch_dtype=torch.float32)
|
10 |
+
|
11 |
+
pipe = pipe.to(device)
|
12 |
+
|
13 |
+
def generatorImage(name):
|
14 |
+
prompt = name
|
15 |
+
image = pipe(prompt).images[0]
|
16 |
+
image_name = '-'.join(prompt.split()) + ".png"
|
17 |
+
image.save("./images/" + image_name)
|
18 |
+
|
19 |
+
return image_name
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
iface = gr.Interface(fn=generatorImage, inputs="text", outputs="text")
|
24 |
+
iface.launch()
|