Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 6 |
+
"stabilityai/stable-diffusion-2-1",
|
| 7 |
+
torch_dtype=torch.float16
|
| 8 |
+
).to("cpu")
|
| 9 |
+
|
| 10 |
+
def generate(prompt):
|
| 11 |
+
image = pipe(prompt).images[0]
|
| 12 |
+
return image
|
| 13 |
+
|
| 14 |
+
demo = gr.Interface(fn=generate, inputs="text", outputs="image")
|
| 15 |
+
demo.launch()
|