Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from diffusers import StableDiffusionPipeline
|
| 4 |
+
|
| 5 |
+
# Load the pretrained text-to-image pipeline
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 7 |
+
"stabilityai/stable-diffusion-2-1",
|
| 8 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 9 |
+
).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 10 |
+
|
| 11 |
+
# Automatically generate a UI from the pipeline
|
| 12 |
+
demo = gr.Interface.from_pipeline(pipe, title="Text-to-Image with Stable Diffusion")
|
| 13 |
+
|
| 14 |
+
demo.launch()
|