Closed uesrs closed 1 year ago
👋 Hello @uesrs, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!
Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.
Check out our YOLOv8 Docs for details and get started with:
pip install ultralytics
@uesrs this issue seems to be related to a missing attribute in the FreeTypeFont
object. However, it is difficult to determine the exact cause without additional information.
Please make sure you are using the latest version of YOLOv5, as this issue could have been resolved in a more recent release. If you are already on the latest version or the issue persists, please provide a minimal reproducible example along with the necessary steps to reproduce the error.
Once we have more information, we will be able to investigate further and provide a solution.
Thank you for your understanding and willingness to contribute!
@uesrs This is caused by new version of Pillow, you can check version of pillow, if version is 10.0.0, just downgrade to pillow 9.5.
@yifeizhangfr, thank you for reporting this issue. It appears that the AttributeError you encountered, 'FreeTypeFont' object has no attribute 'getsize'
, is caused by a compatibility problem with the new version of Pillow.
To resolve this issue, you can try downgrading Pillow to version 9.5 if you are currently using version 10.0.0.
Please let us know if downgrading Pillow solves the problem for you. If you have any further questions or need additional assistance, feel free to ask.
Thank you for your patience and contribution!
@glenn-jocher The problem has been solved.
@yifeizhangfr great to hear that the issue has been resolved! If you encountered any other problems or have any questions, feel free to reach out. Thanks for letting us know and happy coding!
Can confirm, downgrading Pillow to 9.5 works as a fix. Can we get this a commit to the requirements.txt? Or are you making a fix to work with Pillow 10.0.0?
@adamshaeffer thank you for bringing this to our attention. We appreciate you confirming that downgrading Pillow to version 9.5 resolves the issue.
We will consider adding this as a recommendation in the requirements.txt file for YOLOv5. However, we also plan to investigate and address the compatibility issue with Pillow 10.0.0, which will allow users to use the latest version without encountering this problem.
We appreciate your patience and contribution to the YOLOv5 community. If you have any further questions or concerns, please don't hesitate to ask.
Hello! I had the same problem training YOLOv5, and I solved it by downgrading Pillow to version 9.5.
@AlessSilva great to hear that you were able to solve the issue by downgrading Pillow to version 9.5! Thank you for sharing your solution. We will consider adding a recommendation for this in the YOLOv5 documentation. If you have any other questions or need further assistance, feel free to ask.
There may be no impact on learning. However, the images of mosaics will no longer be saved initially.
@Soichi9 thank you for bringing this to our attention. While downgrading Pillow to version 9.5 can resolve the issue of 'FreeTypeFont' object has no attribute 'getsize'
, we are also actively investigating and addressing the compatibility problem with Pillow 10.0.0.
Please note that the downgraded Pillow version does not impact the learning process, but it may affect the initial saving of mosaic images. We appreciate your feedback and patience. If you have any further questions or concerns, please don't hesitate to reach out.
@glenn-jocher I apologize for the confusion. Pillow 10.0.0 may not affect the learning. However, the mosaic images will not be saved in the initial state. 9.5 is normal.
@Soichi9 i appreciate you bringing this to our attention. While Pillow version 10.0.0 may not have any impact on the learning process itself, it can cause an issue where mosaic images are not saved in the initial state. In contrast, Pillow version 9.5 does not exhibit this behavior and works normally. Thank you for your understanding and clarification.
in new pillow 10.0.0
version remove some method and replace.
For More Info see their Doc: pillow documentation
or you can use pillow 9.5.0
@clevermiraz thanks for bringing this to our attention. We are aware of the compatibility issue with Pillow 10.0.0 and the error it causes in YOLOv5 related to the missing method 'getsize'. As you correctly mentioned, Pillow 9.5.0 is a suitable alternative that resolves this problem. We are also actively investigating and addressing the compatibility issue with Pillow 10.0.0 to ensure smooth usage for our users. Thank you for your patience and understanding.
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
now in pillow 10 you can use
Instead of ImageFont.FreeTypeFont(fontfile, size=55, encoding="unic")
and getsize(string)
use ImageFont.truetype(fontfile, size=55, encoding="unic")
and getlength(string)
@IshuSinghSE thanks for sharing the updated usage for Pillow 10! We appreciate your contribution to the YOLOv5 community. Using ImageFont.truetype(fontfile, size=55, encoding="unic")
and getlength(string)
instead of ImageFont.FreeTypeFont(fontfile, size=55, encoding="unic")
and getsize(string)
is indeed the correct approach for Pillow 10. This information will be helpful for other users encountering the same issue. If you have any further questions or need assistance, feel free to ask.
@IshuSinghSE thanks for sharing the updated usage for Pillow 10! We appreciate your contribution to the YOLOv5 community. Using
ImageFont.truetype(fontfile, size=55, encoding="unic")
andgetlength(string)
instead ofImageFont.FreeTypeFont(fontfile, size=55, encoding="unic")
andgetsize(string)
is indeed the correct approach for Pillow 10. This information will be helpful for other users encountering the same issue. If you have any further questions or need assistance, feel free to ask.
Can you tell me which file should be modified?
I also encountered the same problem, and lowering Pillow to 9.5 has been solved
@Adreaming5101 it's great to hear that downgrading to Pillow 9.5 resolved the issue for you! If you have any further questions or need assistance in the future, please feel free to reach out.
@IshuSinghSE thanks for sharing the updated usage for Pillow 10! We appreciate your contribution to the YOLOv5 community. Using
ImageFont.truetype(fontfile, size=55, encoding="unic")
andgetlength(string)
instead ofImageFont.FreeTypeFont(fontfile, size=55, encoding="unic")
andgetsize(string)
is indeed the correct approach for Pillow 10. This information will be helpful for other users encountering the same issue. If you have any further questions or need assistance, feel free to ask.Can you tell me which file should be modified?
Use getlength() ...
@IshuSinghSE apologies for the confusion earlier. To clarify, the getlength()
method does not replace getsize()
. The correct method to use in Pillow 10 for obtaining text size remains getsize()
. If you're experiencing issues with getsize()
, please ensure you're using the ImageFont.truetype()
method to create your font object, as this should still provide the getsize()
method.
If you're still encountering issues, it might be necessary to review the specific code where the error occurs. However, as a general guideline, you would typically look for the usage of getsize()
in the file where you're handling font rendering, which is often in the visualization or drawing sections of the code.
If downgrading to Pillow 9.5 has resolved the issue for you, that's a good temporary solution. We will look into updating the YOLOv5 codebase to be compatible with Pillow 10.0.0 and beyond. If you have any further questions or need more assistance, please let us know.
I had the same problem as @uesrs, but downgrading to Pillow 9.5 didn't work for me. In the error that comes from plots.py, getsize
in line 86 should be replaced by getbbox
like this:
left, top, right, bottom = self.font.getbbox(label)
w = right - left
h = bottom - top
Replacing with get_length doesn't work in this particular case, because w and h are needed in the code.
Thanks @romanwolf-git .The problem doesn't solved with downgrading to Pillow 9.5 but your solution is work for me.
Search before asking
YOLOv5 Component
No response
Bug
我在运行时出现以下错误: AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?