From 1632c27dcc10df787ac68fecc5bde86b296dc4a0 Mon Sep 17 00:00:00 2001 From: livingbody Date: Tue, 18 Jul 2023 16:41:35 +0800 Subject: [PATCH] Update Pillow version to 10.0.0 (#8446) * Update Pillow version to 10.0.0 * upgrade pillow to 10.0.0 * Update Pillow version to 10.0.0 --- deploy/pptracking/python/mot/visualize.py | 3 ++- deploy/python/visualize.py | 9 ++++++--- ppdet/data/transform/operators.py | 3 ++- ppdet/data/transform/rotated_operators.py | 3 ++- ppdet/utils/visualizer.py | 3 ++- requirements.txt | 1 + 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/deploy/pptracking/python/mot/visualize.py b/deploy/pptracking/python/mot/visualize.py index 205f4aac2..8188b056e 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 e964ec05d..239ea01d8 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 23ebd7730..e9e47d0de 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 99dfb572e..175a5499b 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 f7193306c..bd3461d89 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 a094c54ea..da93a6160 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 -- GitLab