Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import eBart
|
|
|
|
| 3 |
|
| 4 |
-
# Load the
|
| 5 |
model = eBart.from_pretrained("dalle-mini/dalle-mega")
|
| 6 |
|
| 7 |
-
# Define
|
| 8 |
-
def generate_image(
|
| 9 |
-
inputs = model.
|
| 10 |
-
outputs = model.generate(
|
| 11 |
-
|
| 12 |
-
return image_url
|
| 13 |
|
| 14 |
-
# Create
|
| 15 |
-
|
| 16 |
-
fn=generate_image,
|
| 17 |
-
inputs="
|
| 18 |
-
outputs="image",
|
| 19 |
-
title="DALL-E Mega Image Generator"
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
-
# Launch the
|
| 23 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import eBart
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
# Load the eBart model
|
| 6 |
model = eBart.from_pretrained("dalle-mini/dalle-mega")
|
| 7 |
|
| 8 |
+
# Define a function to generate an image from text
|
| 9 |
+
def generate_image(prompt):
|
| 10 |
+
inputs = model.prepare_inputs_for_generation(prompt)
|
| 11 |
+
outputs = model.generate(inputs)
|
| 12 |
+
return outputs # You may need to convert it to a displayable image format depending on the model output
|
|
|
|
| 13 |
|
| 14 |
+
# Create Gradio interface
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=generate_image, # Function that takes a prompt and returns an image
|
| 17 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt"), # Textbox input for the prompt
|
| 18 |
+
outputs="image", # Output is an image
|
| 19 |
+
title="eBart DALL-E Mega Image Generator",
|
| 20 |
+
description="Generate images from text prompts using the DALL-E Mega model."
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# Launch the app
|
| 24 |
+
iface.launch()
|