Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,29 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
info_str = f"{hospital['Hospital Name']}\n" \
|
15 |
-
f"{hospital['Address']}\n" \
|
16 |
-
f"{hospital['Number of Hospital Beds']} Beds\n" \
|
17 |
-
f"{hospital['Number of Employees']} Employees\n" \
|
18 |
-
f"{hospital['Services']}"
|
19 |
-
|
20 |
-
return info_str
|
21 |
|
22 |
# Define the Gradio interface
|
23 |
iface = gr.Interface(
|
24 |
-
fn=
|
25 |
-
inputs=gr.inputs.
|
26 |
-
outputs=gr.outputs.
|
27 |
-
title="
|
28 |
-
description="
|
29 |
-
theme="
|
30 |
layout="vertical",
|
31 |
allow_flagging=False
|
32 |
)
|
|
|
1 |
+
from PIL import Image, ImageDraw, ImageFont
|
2 |
import gradio as gr
|
3 |
+
import requests
|
4 |
|
5 |
+
def generate_image(input_text):
|
6 |
+
# Fetch a random quote from the Quote API
|
7 |
+
response = requests.get("https://api.quotable.io/random")
|
8 |
+
quote = response.json()['content']
|
9 |
|
10 |
+
# Create an image with the quote and input text
|
11 |
+
img = Image.new('RGB', (500, 300), color=(255, 255, 255))
|
12 |
+
d = ImageDraw.Draw(img)
|
13 |
+
font = ImageFont.truetype("arial.ttf", 24)
|
14 |
+
d.text((10, 10), quote, font=font, fill=(0, 0, 0))
|
15 |
+
d.text((10, 200), f"You entered: {input_text}", font=font, fill=(0, 0, 0))
|
16 |
|
17 |
+
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# Define the Gradio interface
|
20 |
iface = gr.Interface(
|
21 |
+
fn=generate_image,
|
22 |
+
inputs=gr.inputs.Textbox(placeholder="Enter text here..."),
|
23 |
+
outputs=gr.outputs.Image(label="Generated Image"),
|
24 |
+
title="Creative Image Generator",
|
25 |
+
description="Generate a creative image with a quote using any input text.",
|
26 |
+
theme="default",
|
27 |
layout="vertical",
|
28 |
allow_flagging=False
|
29 |
)
|