rcajegas commited on
Commit
fe69044
1 Parent(s): 18b8552

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -1,32 +1,29 @@
1
- import csv
2
  import gradio as gr
 
3
 
4
- # Load the hospital data from the CSV file
5
- with open('hospital_data.csv', 'r') as f:
6
- reader = csv.DictReader(f)
7
- hospital_data = list(reader)
8
 
9
- def display_hospital_info(index):
10
- # Get the hospital data for the specified index
11
- hospital = hospital_data[index]
 
 
 
12
 
13
- # Format the hospital information as a string
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=display_hospital_info,
25
- inputs=gr.inputs.Slider(minimum=0, maximum=len(hospital_data)-1, step=1, default=0, label="Select a hospital:"),
26
- outputs=gr.outputs.Textbox(label="Hospital Information"),
27
- title="Hospital Information",
28
- description="Display information on hospitals across the United States, including the number of hospital beds, employees, services offered, and address.",
29
- theme="huggingface",
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
  )