Skip to content

Commit

Permalink
[BugFix] Errors in Update pillow (#8460)
Browse files Browse the repository at this point in the history
* fix_textbbox

* compact_py37

* update_req

* fix_deploy_cannot_find
  • Loading branch information
shiyutang authored Jul 24, 2023
1 parent d70598e commit 71d1321
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions deploy/pptracking/python/mot/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
13 changes: 11 additions & 2 deletions deploy/python/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 71d1321

Please sign in to comment.