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