Spaces:
Runtime error
Runtime error
Commit
·
ec221a3
1
Parent(s):
db0a781
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import StableDiffusionPipeline
|
| 3 |
+
|
| 4 |
+
def generate_image(prompt):
|
| 5 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
| 7 |
+
pipe = pipe.to("cuda")
|
| 8 |
+
|
| 9 |
+
image = pipe(prompt).images[0]
|
| 10 |
+
return image
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=generate_image,
|
| 14 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter a prompt for the AI to generate an image."),
|
| 15 |
+
outputs="image",
|
| 16 |
+
title="Stable Diffusion Image Generator",
|
| 17 |
+
description="Enter a prompt and the AI will generate an image for you!",
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
iface.launch()
|