yolov9
yolov9 copied to clipboard
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
When I started training, I had the following problems, and then I started training normally. Is this normal?
Starting training for 100 epochs...
Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size
0/99 3.01G 5.309 6.831 5.464 28 640: 0%| | 0/3520 00:14Exception in thread Thread-7:
Traceback (most recent call last): File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 300, in plot_images annotator.box_label(box, label, color=color) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 86, in box_label w, h = self.font.getsize(label) # text width, height AttributeError: 'FreeTypeFont' object has no attribute 'getsize' WARNING ⚠️ TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions 0/99 3.53G 4.76 6.78 5.595 165 640: 0%| | 2/3520 00:18Exception in thread Thread-10: Traceback (most recent call last): File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 300, in plot_images annotator.box_label(box, label, color=color) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 86, in box_label w, h = self.font.getsize(label) # text width, height AttributeError: 'FreeTypeFont' object has no attribute 'getsize' 0/99 3.53G 4.231 6.698 5.599 42 640: 0%| | 3/3520 00:19Exception in thread Thread-13: Traceback (most recent call last): File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/home/Users/anaconda3/envs/detr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 300, in plot_images annotator.box_label(box, label, color=color) File "/home/Users/桌面/yolov9-main/utils/plots.py", line 86, in box_label w, h = self.font.getsize(label) # text width, height AttributeError: 'FreeTypeFont' object has no attribute 'getsize' 0/99 4.48G 4.757 7.121 5.501 67 640: 8%|▊ | 289/3520 03:37
You may need reinstall your Pillow, for example pip install Pillow==9.5.0
.
Thank you, it was very useful and has been resolved
Hi, I use YOLO for an industrial application, and I wanted to collaborate:
I replaced line 86 in plots.py:
w, h = self.font.getsize(label) # text width, height
I read in the PIL docs that getsize is now deprecated and was replaced by ImageFont.getbbox() and ImageFont.getlength().
In the source code of getbbox, shows that it returns 4 elements:
return 0, 0, width, height
So I did this:
unused1,unused2,w, h = self.font.getbbox(label) # text width, height
And the error was solved.
I apologize in advance if I'm commenting in a closed thread. Have a great day.
Recommend re-opening this issue, either until a patch is merged in or requirements.txt
specifies this version. If installing yolov9 with the existing requirements.txt, this error will always occur
You may need reinstall your Pillow, for example
pip install Pillow==9.5.0
.
Related to PR #97