From 71d132170778816eedd4f2285c3b8a1d43609162 Mon Sep 17 00:00:00 2001 From: shiyutang <34859558+shiyutang@users.noreply.github.com> Date: Mon, 24 Jul 2023 10:09:03 +0800 Subject: [PATCH] [BugFix] Errors in Update pillow (#8460) * fix_textbbox * compact_py37 * update_req * fix_deploy_cannot_find --- deploy/pptracking/python/mot/visualize.py | 10 ++++++++++ deploy/python/visualize.py | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/deploy/pptracking/python/mot/visualize.py b/deploy/pptracking/python/mot/visualize.py index e60b73280..66d3a66eb 100644 --- a/deploy/pptracking/python/mot/visualize.py +++ b/deploy/pptracking/python/mot/visualize.py @@ -17,12 +17,22 @@ from __future__ import division import os import cv2 import numpy as np +import PIL from PIL import Image, ImageDraw, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True from collections import deque from ppdet.utils.compact import imagedraw_textsize_c +def imagedraw_textsize_c(draw, text): + if int(PIL.__version__.split('.')[0]) < 10: + tw, th = draw.textsize(text) + else: + left, top, right, bottom = draw.textbbox((0, 0), text) + tw, th = right - left, bottom - top + + return tw, th + def visualize_box_mask(im, results, labels, threshold=0.5): """ diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index 51e01b9d9..9e96c29df 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -16,12 +16,21 @@ from __future__ import division import os import cv2 +import math import numpy as np +import PIL from PIL import Image, ImageDraw, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True -import math -from ppdet.utils.compact import imagedraw_textsize_c +def imagedraw_textsize_c(draw, text): + if int(PIL.__version__.split('.')[0]) < 10: + tw, th = draw.textsize(text) + else: + left, top, right, bottom = draw.textbbox((0, 0), text) + tw, th = right - left, bottom - top + + return tw, th + def visualize_box_mask(im, results, labels, threshold=0.5): """ -- GitLab