File size: 588 Bytes
5e69d3c
289c4e6
d13afd7
289c4e6
 
d13afd7
289c4e6
 
 
 
 
 
5e69d3c
289c4e6
 
5e69d3c
289c4e6
 
 
5e69d3c
 
289c4e6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import eBart

# Load the DALL-E Mega model
model = eBart.from_pretrained("dalle-mini/dalle-mega")

# Define the function to generate images
def generate_image(text):
    inputs = model.tokenizer(text, return_tensors="pt")
    outputs = model.generate(**inputs)
    image_url = model.tokenizer.decode(outputs[0], skip_special_tokens=True)
    return image_url

# Create the Gradio interface
ui = gr.Interface(
    fn=generate_image,
    inputs="text",
    outputs="image",
    title="DALL-E Mega Image Generator"
)

# Launch the Gradio app
ui.launch()