Skip to content

Commit c157ca1

Browse files
authored
[BugFix] Update pillow usage (#16269)
[BugFix] Update textsize usage
1 parent 8b2cff8 commit c157ca1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/tvm/relay/testing/yolo_detection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,12 @@ def _get_label(font_path, labelstr, rgb):
315315
from PIL import ImageFont
316316

317317
text = labelstr
318+
textSize = 25
318319
colorText = "black"
319320
testDraw = ImageDraw.Draw(Image.new("RGB", (1, 1)))
320-
font = ImageFont.truetype(font_path, 25)
321-
width, height = testDraw.textsize(labelstr, font=font)
321+
font = ImageFont.truetype(font_path, textSize)
322+
width = int(testDraw.textlength(labelstr, font=font))
323+
height = textSize + 5
322324
img = Image.new(
323325
"RGB", (width, height), color=(int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255))
324326
)

0 commit comments

Comments
 (0)