Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error of getsize #604

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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