-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
7.0版本首次运行报错AttributeError: 'FreeTypeFont' object has no attribute 'getsize' #13342
Comments
👋 Hello @MonHer, thank you for reaching out and for your interest in YOLOv5 🚀! It seems you're encountering an issue related to the To assist us in resolving this bug more effectively, could you provide a minimum reproducible example (MRE)? This will help our team understand the issue better. In the meantime, ensure your environment is set up as per the requirements: Requirements
EnvironmentsYou can run YOLOv5 in various environments, including: An Ultralytics engineer will review your issue further. Thank you for your patience and contribution! 😊 🔍 For a more detailed exploration, check our ⭐️ Tutorials. |
Search before asking
YOLOv5 Component
Training
Bug
报错日志:
#导致原因
这个错误是由于 FreeTypeFont 对象没有 getsize() 方法引起的,这通常是因为 Pillow 版本的问题。自 Pillow 10.0.0 版本起,getsize() 方法被弃用,改为了 textsize() 或 getbbox()
解决办法:
解决方法:
有两种方式可以解决这个问题:
1. 降级 Pillow 版本
YOLOv5 和其他旧代码可能依赖于较早版本的 Pillow,因此降级 Pillow 到适合的版本(比如 9.x.x 版本)可以解决这个问题。使用以下命令降级 Pillow:
这样可以确保旧的 getsize() 方法在 FreeTypeFont 中可用。
2. 修改代码适应新的 Pillow 版本
如果你希望使用较新的 Pillow 版本,可以通过修改 plots.py 文件中的代码,使用新的 getbbox() 方法替换 getsize()。修改代码如下
update 为:
getbbox() 返回一个 4 元素的元组 (left, top, right, bottom),其中 right-left 就是宽度,bottom-top 就是高度
Environment
Minimal Reproducible Example
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: