Open Hezhing opened 9 months ago
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
Hi, I recommend @moralesja560 's solution rather than downgrading pillow.
When I ran the program with version 9.5.0 of pillow, it abruptly terminated without outputting any error messages. (environment: torch2.3.1, torchvision0.18.1). It seems that pilllow 9.5.0 is sometimes incompatible with new torchvision. (https://github.com/pytorch/vision/issues/7660)
+1
error:
$ fp --version
fp 1.2.0
$ fp Papyrus.ttf
Traceback (most recent call last):
File "/opt/homebrew/bin/fp", line 105, in <module>
fp = FontPreview(**fpargs)
File "/opt/homebrew/lib/python3.13/site-packages/fontpreview/fontpreview.py", line 80, in __init__
self.font_position = CALC_POSITION['center'](self.dimension, self.font.getsize(self.font_text))
^^^^^^^^^^^^^^^^^
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
installation details:
$ pip install fontpreview
Collecting fontpreview
Downloading fontpreview-1.2.0.tar.gz (16 kB)
Preparing metadata (setup.py) ... done
Collecting Pillow (from fontpreview)
Downloading pillow-11.0.0-cp313-cp313-macosx_11_0_arm64.whl.metadata (9.1 kB)
Downloading pillow-11.0.0-cp313-cp313-macosx_11_0_arm64.whl (3.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 1.4 MB/s eta 0:00:00
Building wheels for collected packages: fontpreview
Building wheel for fontpreview (setup.py) ... done
Created wheel for fontpreview: filename=fontpreview-1.2.0-py3-none-any.whl size=15619 sha256=ccaba7266f83e710f62b17b613d08ea6b14d0e76eabc2b2a2fbd57a5658b8c16
Stored in directory: /Users/marslo/Library/Caches/pip/wheels/d2/db/0b/d06a8bfff1dbdcc4758caba299cd686f712a5a33cc5685aa0a
Successfully built fontpreview
Installing collected packages: Pillow, fontpreview
Successfully installed Pillow-11.0.0 fontpreview-1.2.0
environment:
$ python3 -m pip list | grep -E 'font|pillow'
font-size 0.1.2
fontpreview 1.2.0
fonttools 4.54.1
pillow 11.0.0
$ python3 --version
Python 3.13.0
$ sw_vers
ProductName: macOS
ProductVersion: 14.7.1
BuildVersion: 23H222
When I started training, I had the following problems, and then I started training normally. Is this normal?
Starting training for 100 epochs...
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