diff --git a/deploy/pptracking/python/mot/visualize.py b/deploy/pptracking/python/mot/visualize.py index 205f4aac2312e1c7238cfd16490e416b2e5dfe8f..8188b056e328ab720442c2c8a9f0a58c5aa7a26b 100644 --- a/deploy/pptracking/python/mot/visualize.py +++ b/deploy/pptracking/python/mot/visualize.py @@ -109,7 +109,8 @@ def draw_box(im, np_boxes, labels, threshold=0.5): # draw label text = "{} {:.4f}".format(labels[clsid], score) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color) draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255)) diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index e964ec05df3ea1e0c6759e080fd4c001c9dc78e5..239ea01d83a4eb36b75a036e06fa85bcb3e2c51b 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -159,7 +159,8 @@ def draw_box(im, np_boxes, labels, threshold=0.5): # draw label text = "{} {:.4f}".format(labels[clsid], score) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color) draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255)) @@ -497,7 +498,8 @@ def draw_press_box_lanes(im, np_boxes, labels, threshold=0.5): # draw label text = "{}".format(labels[clsid]) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymax - th), (xmin + tw + 1, ymax)], fill=color) draw.text((xmin + 1, ymax - th), text, fill=(0, 0, 255)) @@ -570,7 +572,8 @@ def visualize_vehicle_retrograde(im, mot_res, vehicle_retrograde_res): # draw label text = "retrograde" - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmax + 1, ymin - th), (xmax + tw + 1, ymin)], fill=(0, 255, 0)) diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index 23ebd7730d3cc22252934cebdedaa264d54ade76..e9e47d0de5a137ddc6c545c29df119ec7f1b1891 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -2212,7 +2212,8 @@ class DebugVisibleImage(BaseOperator): fill='green') # draw label text = str(gt_class[i][0]) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill='green') draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255)) diff --git a/ppdet/data/transform/rotated_operators.py b/ppdet/data/transform/rotated_operators.py index 99dfb572e6c730d651b5169c74cdecaffce8fe7b..175a5499bb9e9ef689458dfa9881568d9f6dedbc 100644 --- a/ppdet/data/transform/rotated_operators.py +++ b/ppdet/data/transform/rotated_operators.py @@ -433,7 +433,8 @@ class VisibleRBox(BaseOperator): xmin = min(x1, x2, x3, x4) ymin = min(y1, y2, y3, y4) text = str(gt_class[i][0]) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill='green') draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255)) diff --git a/ppdet/utils/visualizer.py b/ppdet/utils/visualizer.py index f7193306c93e0917ee400df3f76f28a3f436df08..bd3461d89128db95a23590a82bee1dc0c4f05c8a 100644 --- a/ppdet/utils/visualizer.py +++ b/ppdet/utils/visualizer.py @@ -125,7 +125,8 @@ def draw_bbox(image, im_id, catid2name, bboxes, threshold): # draw label text = "{} {:.2f}".format(catid2name[catid], score) - tw, th = draw.textsize(text) + left, top, right, bottom = draw.textbbox(text) + tw, th = right - left, bottom - top draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color) draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255)) diff --git a/requirements.txt b/requirements.txt index a094c54eaff7092a302c68c5bae3b76249b79a6c..da93a616019e487d34255d11ee2b1af719159dd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ terminaltables Cython pycocotools setuptools +Pillow>=10.0.0 # for MOT evaluation and inference lap