Nojoodalnahdi commited on
Commit
1f46c17
1 Parent(s): 8fe8504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -8,11 +8,8 @@ def greet(name):
8
  # Initialize the drawing context with the image object
9
  d = ImageDraw.Draw(img)
10
 
11
- # Load a font (You can replace this with a path to a .ttf file if needed)
12
- try:
13
- font = ImageFont.truetype("arial.ttf", 40) # Use a specific font and size
14
- except IOError:
15
- font = ImageFont.load_default() # Fallback to default font if the specific font is not found
16
 
17
  # Define the text
18
  text = f"Hello {name}!!"
@@ -24,7 +21,7 @@ def greet(name):
24
  x = (img.width - text_width) // 2
25
  y = (img.height - text_height) // 2
26
 
27
- # Add text to image
28
  d.text((x, y), text, fill=(0, 0, 0), font=font)
29
 
30
  # Return the image
@@ -35,3 +32,4 @@ demo = gr.Interface(fn=greet, inputs="text", outputs="image")
35
 
36
  # Launch the app
37
  demo.launch()
 
 
8
  # Initialize the drawing context with the image object
9
  d = ImageDraw.Draw(img)
10
 
11
+ # Use the default font provided by PIL (no need to specify a path)
12
+ font = ImageFont.load_default()
 
 
 
13
 
14
  # Define the text
15
  text = f"Hello {name}!!"
 
21
  x = (img.width - text_width) // 2
22
  y = (img.height - text_height) // 2
23
 
24
+ # Add text to the image
25
  d.text((x, y), text, fill=(0, 0, 0), font=font)
26
 
27
  # Return the image
 
32
 
33
  # Launch the app
34
  demo.launch()
35
+