diff --git a/deploy/pptracking/python/mot/visualize.py b/deploy/pptracking/python/mot/visualize.py index e60b732808f..66d3a66ebdd 100644 --- a/deploy/pptracking/python/mot/visualize.py +++ b/deploy/pptracking/python/mot/visualize.py @@ -17,12 +17,22 @@ 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 51e01b9d92e..9e96c29df06 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -16,12 +16,21 @@ 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): """