Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
model_id = "SG161222/Realistic_Vision_V5.1_noVAE"
|
| 6 |
+
|
| 7 |
+
# float16 + GPU
|
| 8 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 9 |
+
model_id,
|
| 10 |
+
torch_dtype=torch.float16
|
| 11 |
+
)
|
| 12 |
+
pipe.to("cuda")
|
| 13 |
+
|
| 14 |
+
def infer(prompt):
|
| 15 |
+
image = pipe(prompt).images[0]
|
| 16 |
+
return image
|
| 17 |
+
|
| 18 |
+
demo = gr.Interface(
|
| 19 |
+
fn=infer,
|
| 20 |
+
inputs=gr.Textbox(label="Prompt"),
|
| 21 |
+
outputs=gr.Image(label="Generated Image")
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
demo.launch()
|