运行yolov5报错:AttributeError: ‘FreeTypeFont‘ object has no attribute ‘getsize‘ 记录错误(已经找到解决办法)

在我运行yolov5的时候程序是一直在运行,但总是报这个错误

Exception in thread Thread-607:
Traceback (most recent call last):
  File "/opt/conda/envs/yolo_v5/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/opt/conda/envs/yolo_v5/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/djtu22/wym1/yolov5-master/utils/plots.py", line 290, in plot_images
    annotator.box_label(box, label, color=color)
  File "/djtu22/wym1/yolov5-master/utils/plots.py", line 91, in box_label
    w, h = self.font.getsize(label)  # text width, height (WARNING: deprecated) in 9.2.0
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
Exception in thread Thread-608:
Traceback (most recent call last):
  File "/opt/conda/envs/yolo_v5/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/opt/conda/envs/yolo_v5/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/djtu22/wym1/yolov5-master/utils/plots.py", line 290, in plot_images
    annotator.box_label(box, label, color=color)
  File "/djtu22/wym1/yolov5-master/utils/plots.py", line 91, in box_label
    w, h = self.font.getsize(label)  # text width, height (WARNING: deprecated) in 9.2.0
AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

这是因为安装了新版本的 Pillow (10),pip install tf-models-official删除了该getsize 功能
,降级到 Pillow 9.5 解决了该问题

可以尝试以下方法进行解决:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  Pillow==9.5
  • 11
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我要变胖哇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值