Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,20 @@
|
|
1 |
-
# app.py
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
# Initialize
|
6 |
generator = pipeline("image-generation", model="CompVis/stable-diffusion-v1-4")
|
7 |
|
8 |
-
# Function to generate
|
9 |
def generate_image(prompt):
|
10 |
-
# The pipeline will return a list with the image as the first element
|
11 |
return generator(prompt)[0]["image"]
|
12 |
|
13 |
-
#
|
14 |
interface = gr.Interface(
|
15 |
-
fn=generate_image,
|
16 |
-
inputs="text",
|
17 |
-
outputs="image",
|
18 |
-
live=True
|
19 |
)
|
20 |
|
21 |
# Launch the interface
|
22 |
-
|
23 |
-
interface.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize your model here
|
5 |
generator = pipeline("image-generation", model="CompVis/stable-diffusion-v1-4")
|
6 |
|
7 |
+
# Function to generate image from text prompt
|
8 |
def generate_image(prompt):
|
|
|
9 |
return generator(prompt)[0]["image"]
|
10 |
|
11 |
+
# Define Gradio Interface
|
12 |
interface = gr.Interface(
|
13 |
+
fn=generate_image,
|
14 |
+
inputs="text", # User will input text prompt
|
15 |
+
outputs="image", # The output will be an image
|
16 |
+
live=True
|
17 |
)
|
18 |
|
19 |
# Launch the interface
|
20 |
+
interface.launch()
|
|