Spaces:
Runtime error
Runtime error
Update viz_utils.py
Browse files- viz_utils.py +2 -12
viz_utils.py
CHANGED
|
@@ -8,11 +8,6 @@ import numpy as np
|
|
| 8 |
import pdb
|
| 9 |
from datetime import date
|
| 10 |
today = date.today()
|
| 11 |
-
FONTS = {'amiko': "fonts/Amiko-Regular.ttf",
|
| 12 |
-
'nature': "fonts/LoveNature.otf",
|
| 13 |
-
'painter':"fonts/PainterDecorator.otf",
|
| 14 |
-
'animals': "fonts/UncialAnimals.ttf",
|
| 15 |
-
'zen': "fonts/ZEN.TTF"}
|
| 16 |
|
| 17 |
#########################################
|
| 18 |
# Draw keypoints on image
|
|
@@ -21,7 +16,6 @@ def draw_keypoints_on_image(image,
|
|
| 21 |
map_label_id_to_str,
|
| 22 |
flag_show_str_labels,
|
| 23 |
use_normalized_coordinates=True,
|
| 24 |
-
font_style='amiko',
|
| 25 |
font_size=8,
|
| 26 |
keypt_color="#ff0000",
|
| 27 |
marker_size=2,
|
|
@@ -73,18 +67,15 @@ def draw_keypoints_on_image(image,
|
|
| 73 |
|
| 74 |
# add string labels around keypoints
|
| 75 |
if flag_show_str_labels:
|
| 76 |
-
font = ImageFont.truetype(FONTS[font_style],
|
| 77 |
-
font_size)
|
| 78 |
draw.text((keypoint_x + marker_size, keypoint_y + marker_size),#(0.5*im_width, 0.5*im_height), #-------
|
| 79 |
map_label_id_to_str[i],
|
| 80 |
-
ImageColor.getcolor(keypt_color, "RGB")
|
| 81 |
-
|
| 82 |
|
| 83 |
#########################################
|
| 84 |
# Draw bboxes on image
|
| 85 |
def draw_bbox_w_text(img,
|
| 86 |
results,
|
| 87 |
-
font_style='amiko',
|
| 88 |
font_size=8): #TODO: select color too?
|
| 89 |
#pdb.set_trace()
|
| 90 |
bbxyxy = results
|
|
@@ -95,7 +86,6 @@ def draw_bbox_w_text(img,
|
|
| 95 |
|
| 96 |
confidence = bbxyxy[4]
|
| 97 |
string_bb = 'animal ' + str(round(confidence, 2))
|
| 98 |
-
font = ImageFont.truetype(FONTS[font_style], font_size)
|
| 99 |
|
| 100 |
text_size = font.getsize(string_bb) # (h,w)
|
| 101 |
position = (bbxyxy[0],bbxyxy[1] - text_size[1] -2 )
|
|
|
|
| 8 |
import pdb
|
| 9 |
from datetime import date
|
| 10 |
today = date.today()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
#########################################
|
| 13 |
# Draw keypoints on image
|
|
|
|
| 16 |
map_label_id_to_str,
|
| 17 |
flag_show_str_labels,
|
| 18 |
use_normalized_coordinates=True,
|
|
|
|
| 19 |
font_size=8,
|
| 20 |
keypt_color="#ff0000",
|
| 21 |
marker_size=2,
|
|
|
|
| 67 |
|
| 68 |
# add string labels around keypoints
|
| 69 |
if flag_show_str_labels:
|
|
|
|
|
|
|
| 70 |
draw.text((keypoint_x + marker_size, keypoint_y + marker_size),#(0.5*im_width, 0.5*im_height), #-------
|
| 71 |
map_label_id_to_str[i],
|
| 72 |
+
ImageColor.getcolor(keypt_color, "RGB") # rgb #
|
| 73 |
+
)
|
| 74 |
|
| 75 |
#########################################
|
| 76 |
# Draw bboxes on image
|
| 77 |
def draw_bbox_w_text(img,
|
| 78 |
results,
|
|
|
|
| 79 |
font_size=8): #TODO: select color too?
|
| 80 |
#pdb.set_trace()
|
| 81 |
bbxyxy = results
|
|
|
|
| 86 |
|
| 87 |
confidence = bbxyxy[4]
|
| 88 |
string_bb = 'animal ' + str(round(confidence, 2))
|
|
|
|
| 89 |
|
| 90 |
text_size = font.getsize(string_bb) # (h,w)
|
| 91 |
position = (bbxyxy[0],bbxyxy[1] - text_size[1] -2 )
|