From 5b2513e92cb736e053f4a8f1257c54f661825e98 Mon Sep 17 00:00:00 2001 From: Yudai Fujimoto Date: Thu, 21 Dec 2023 08:27:09 +0000 Subject: [PATCH] [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)) )