singam96 commited on
Commit
39a275f
·
1 Parent(s): f471943
Files changed (1) hide show
  1. inference_utils.py +20 -0
inference_utils.py CHANGED
@@ -157,6 +157,26 @@ def _draw_arrow(img: Image.Image, color=(180, 180, 180)) -> Image.Image:
157
  return img
158
 
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  def make_side_by_side(inp_img: Image.Image, outputs: dict) -> Image.Image:
161
  inp_img = inp_img.convert("RGB")
162
 
 
157
  return img
158
 
159
 
160
+ def _draw_label(img: Image.Image, label: str, bar_color=(0, 0, 0)) -> Image.Image:
161
+ draw = ImageDraw.Draw(img)
162
+ try:
163
+ font = ImageFont.truetype("arial.ttf", 18)
164
+ except OSError:
165
+ font = ImageFont.load_default()
166
+ draw.rectangle((0, 0, img.width, 24), fill=bar_color)
167
+ draw.text((4, 2), label, fill=(255, 255, 255), font=font)
168
+ return img
169
+
170
+
171
+ def _draw_arrow(img: Image.Image, color=(180, 180, 180)) -> Image.Image:
172
+ draw = ImageDraw.Draw(img)
173
+ cx, cy = img.width // 2, img.height // 2
174
+ r = 8
175
+ draw.line((0, cy, img.width - r, cy), fill=color, width=3)
176
+ draw.polygon([(img.width - r, cy - r), (img.width - r, cy + r), (img.width, cy)], fill=color)
177
+ return img
178
+
179
+
180
  def make_side_by_side(inp_img: Image.Image, outputs: dict) -> Image.Image:
181
  inp_img = inp_img.convert("RGB")
182