Skip to content

Conversation

@rabinandan
Copy link

@rabinandan rabinandan commented Oct 15, 2024

Execution of the code gives the following error
File "/content/yolov9/utils/plots.py", line 300, in plot_images
annotator.box_label(box, label, color=color)
File "/content/yolov9/utils/plots.py", line 86, in box_label
w, h = self.font.getsize(label) # text width, height
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

Changes made

#Old code:
w, h = self.font.getsize(label)  # text width, height

#New code:
w, h = self.font.getbbox(label)[2:4]  # bounding box, get width and height

AND

# Old code
w, h = self.font.getsize(text)  # text width, height

#New code:
w, h = self.font.getbbox(text)[2:4]  # get bounding box, extract width and height

Replaced self.font.getsize(label) and self.font.getbbox(text)[2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant