From c157ca1a52e4e59fa24145c21b22d4c063750ad0 Mon Sep 17 00:00:00 2001 From: Yudai Fujimoto <52846256+Apricot256@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:45:00 +0900 Subject: [PATCH] [BugFix] Update pillow usage (#16269) [BugFix] Update textsize usage --- python/tvm/relay/testing/yolo_detection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/tvm/relay/testing/yolo_detection.py b/python/tvm/relay/testing/yolo_detection.py index f486e0d7e874..7a54961891b1 100644 --- a/python/tvm/relay/testing/yolo_detection.py +++ b/python/tvm/relay/testing/yolo_detection.py @@ -315,10 +315,12 @@ def _get_label(font_path, labelstr, rgb): from PIL import ImageFont text = labelstr + textSize = 25 colorText = "black" testDraw = ImageDraw.Draw(Image.new("RGB", (1, 1))) - font = ImageFont.truetype(font_path, 25) - width, height = testDraw.textsize(labelstr, font=font) + font = ImageFont.truetype(font_path, textSize) + width = int(testDraw.textlength(labelstr, font=font)) + height = textSize + 5 img = Image.new( "RGB", (width, height), color=(int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)) )