File size: 1,030 Bytes
fe69044
18b8552
fe69044
6c311bc
fe69044
 
 
 
6c311bc
fe69044
 
 
 
 
 
18b8552
fe69044
18b8552
 
 
fe69044
 
 
 
 
 
18b8552
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from PIL import Image, ImageDraw, ImageFont
import gradio as gr
import requests

def generate_image(input_text):
    # Fetch a random quote from the Quote API
    response = requests.get("https://api.quotable.io/random")
    quote = response.json()['content']

    # Create an image with the quote and input text
    img = Image.new('RGB', (500, 300), color=(255, 255, 255))
    d = ImageDraw.Draw(img)
    font = ImageFont.truetype("arial.ttf", 24)
    d.text((10, 10), quote, font=font, fill=(0, 0, 0))
    d.text((10, 200), f"You entered: {input_text}", font=font, fill=(0, 0, 0))

    return img

# Define the Gradio interface
iface = gr.Interface(
    fn=generate_image,
    inputs=gr.inputs.Textbox(placeholder="Enter text here..."),
    outputs=gr.outputs.Image(label="Generated Image"),
    title="Creative Image Generator",
    description="Generate a creative image with a quote using any input text.",
    theme="default",
    layout="vertical",
    allow_flagging=False
)

# Launch the Gradio interface
iface.launch()