Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,2 +1,24 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Initialize the model (example with a text-to-image model)
|
6 |
+
generator = pipeline("image-generation", model="CompVis/stable-diffusion-v1-4")
|
7 |
+
|
8 |
+
# Function to generate an image from a prompt
|
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 |
+
# Set up the Gradio interface
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=generate_image, # function to be called
|
16 |
+
inputs="text", # input type: text box for user input (prompt)
|
17 |
+
outputs="image", # output type: image display
|
18 |
+
live=True # allows real-time generation (optional)
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the interface
|
22 |
+
if __name__ == "__main__":
|
23 |
+
interface.launch()
|
24 |
+
|