jonathang commited on
Commit
95c34a4
1 Parent(s): 46617f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -17,6 +17,7 @@ import PIL.ImageDraw
17
  import PIL.ImageFont
18
  import gradio as gr
19
  import cachetools.func
 
20
 
21
 
22
  logger = structlog.getLogger()
@@ -25,6 +26,8 @@ openai.api_key = os.environ.get("OPENAI_KEY", None)
25
 
26
  animals = [x.strip() for x in open('animals.txt').readlines()]
27
  art_styles = [x.strip() for x in open('art_styles.txt').readlines()]
 
 
28
 
29
 
30
  class Chat:
@@ -140,7 +143,7 @@ def overlay_text_on_image(img, text, position, text_color=(255, 255, 255), box_c
140
  l, r = 1, 50
141
  while l < r:
142
  font_size = (l + r) // 2
143
- font = PIL.ImageFont.truetype("/System/Library/Fonts/NewYork.ttf", font_size)
144
  left, upper, right, lower = draw.textbbox((0, 0), text, font=font)
145
  text_width = right - left
146
  text_height = lower - upper
 
17
  import PIL.ImageFont
18
  import gradio as gr
19
  import cachetools.func
20
+ from huggingface_hub import hf_hub_download
21
 
22
 
23
  logger = structlog.getLogger()
 
26
 
27
  animals = [x.strip() for x in open('animals.txt').readlines()]
28
  art_styles = [x.strip() for x in open('art_styles.txt').readlines()]
29
+ font_path = hf_hub_download("ybelkada/fonts", "Arial.TTF")
30
+
31
 
32
 
33
  class Chat:
 
143
  l, r = 1, 50
144
  while l < r:
145
  font_size = (l + r) // 2
146
+ font = PIL.ImageFont.truetype(font_path, font_size)
147
  left, upper, right, lower = draw.textbbox((0, 0), text, font=font)
148
  text_width = right - left
149
  text_height = lower - upper