Sartc commited on
Commit
8d33cab
·
verified ·
1 Parent(s): 3e855cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  from PIL import Image, ImageDraw, ImageFont
3
  import numpy as np
@@ -14,7 +15,9 @@ def process_image(image, text, font_size):
14
  print(f"image: {image}")
15
  background_with_text = image.copy()
16
  draw = ImageDraw.Draw(background_with_text)
17
- font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", font_size)
 
 
18
  text_position = (50, 50)
19
  text_color = (0, 0, 0)
20
  draw.text(text_position, text, fill=text_color, font=font)
 
1
+ import os
2
  import gradio as gr
3
  from PIL import Image, ImageDraw, ImageFont
4
  import numpy as np
 
15
  print(f"image: {image}")
16
  background_with_text = image.copy()
17
  draw = ImageDraw.Draw(background_with_text)
18
+ current_dir = os.path.dirname(__file__)
19
+ font_path = os.path.join(current_dir, "FreeSansBold.ttf")
20
+ font = ImageFont.truetype(font_path, font_size)
21
  text_position = (50, 50)
22
  text_color = (0, 0, 0)
23
  draw.text(text_position, text, fill=text_color, font=font)