Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model for image generation
|
5 |
+
generator = pipeline('text-to-image', model='CompVis/stable-diffusion-v1-4', device=0) # Use your model here
|
6 |
+
|
7 |
+
def generate_image(description):
|
8 |
+
# Generate image from description
|
9 |
+
image = generator(description)[0]
|
10 |
+
return image
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_image,
|
15 |
+
inputs="text",
|
16 |
+
outputs="image",
|
17 |
+
live=True,
|
18 |
+
description="Enter a description to generate an image (e.g., 'A boy holding a bag')"
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the interface
|
22 |
+
iface.launch()
|