-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Problems with quantized model #12609
Comments
👋 Hello @joaopdss, 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. RequirementsPython>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. Introducing YOLOv8 🚀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 |
@joaopdss hello! Thanks for reaching out with your quantization issue. Quantization can indeed introduce some discrepancies due to the reduced precision of the model weights and activations. Here are a few things to consider:
If you continue to face issues, consider providing more details on the quantization process you followed, and check out our documentation for any additional guidance. Keep in mind that quantization is a trade-off between model size, speed, and accuracy. 🤖🔍 |
The thing that does not make sense for me is that I am exporting with the YoloV5 Ultranalytics way and executing with the same scripts the non quantized and quantized models, and the results have a huge difference. export line:
execution line:
some results with the non quantized model: same results with the quantized model: Maybe is there something missing in the export.py line? I know the results can be different from both models but the difference is just too much, does not make sense for me |
@joaopdss, it's clear that the quantization is having a significant impact on your model's performance. The discrepancy you're observing is indeed larger than one might typically expect. Here are a few additional steps to consider:
If these steps don't resolve the issue, it might be helpful to open a detailed issue on the YOLOv5 repository with all the information you've gathered, including the exact commands used, sample outputs, and any other relevant details. This can help the community to provide more targeted assistance. Remember, quantization is complex, and sometimes it requires a bit of trial and error to get right. 🛠️🧐 |
I solved the issue, looks like there is some problem with the recent versions of TensorFlow when applying Post-training quantization. I ran the quantization script (export.py) again but with Tensorflow 2.12.0 and it worked. |
@joaopdss, that's great news! I'm glad to hear you were able to resolve the issue by using TensorFlow 2.12.0 for the quantization process. It's not uncommon for different versions of TensorFlow to behave differently, especially with operations as sensitive as quantization. Your findings could be valuable for others in the community facing similar issues, so thank you for sharing your solution. If you encounter any more challenges or have further questions as you continue working with YOLOv5, feel free to reach out. Happy detecting! 😊👍 |
Thank you!! i solved same problem with Tensorflow 2.12.0 !! 😊 |
You're welcome! I'm glad it worked out with TensorFlow 2.12.0. If you have any more questions, feel free to ask. |
Thanks for this thread, |
Glad TensorFlow 2.12.0 worked for you! 🚀 For others facing similar issues, ensure you follow our TFLite export guide and verify TF compatibility. If problems persist, share your exact environment details for community help. |
Search before asking
Question
Hey, I've been having some problems with the YoloV5 model after quantization:
Not exactly sure if it's something related to my input, but I don't think so
I'll provide a part of my code below
Code for quantized (uint8) model:
output:
after applying NMS, we have the following results
![image](https://private-user-images.githubusercontent.com/72708214/295685678-c370b9a8-41fd-4b52-af32-00968c1a093c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDUzMjYsIm5iZiI6MTczOTM0NTAyNiwicGF0aCI6Ii83MjcwODIxNC8yOTU2ODU2NzgtYzM3MGI5YTgtNDFmZC00YjUyLWFmMzItMDA5NjhjMWEwOTNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MjM0NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU2ZDg1ZTYxMjViODI5MDZhZjc3Y2QzOTk5ZmVjMjYzMDY3NWRjYTUwZWIxZmU0YWE2MWQ5Nzk3NzVhM2ZiYmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ct1I4XQi9wBi_KjeciutYStWmKizq6FN3KK4-AfbB10)
Code for non quantized (float32) model:
output:
after applying NMS, we have the following results
![image](https://private-user-images.githubusercontent.com/72708214/295690020-afb09f79-a700-4c5a-bdaa-51348e0d0b71.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDUzMjYsIm5iZiI6MTczOTM0NTAyNiwicGF0aCI6Ii83MjcwODIxNC8yOTU2OTAwMjAtYWZiMDlmNzktYTcwMC00YzVhLWJkYWEtNTEzNDhlMGQwYjcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDA3MjM0NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThlZWM1ZjIyNWMzMDE0ZjI0OTAwZWNhNmY4YzhlY2UzOTMwYzliMmZhNjk5N2RjMDZlMWVlZmFkYTIyODUwY2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KXPejYLC51B5tdF55GthTXTglnrQO96Sd-TVuCSlibU)
Any ideas about the reason I am getting these huge differences between the results? Am I doing something wrong with the input for the quantized model?
And why the output of the quantized model is like this?
Additional
No response
The text was updated successfully, but these errors were encountered: