Skip to content
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

Limit tensorflow version and add checks #12494

Merged
merged 6 commits into from
Dec 16, 2023

Conversation

Corallo
Copy link
Contributor

@Corallo Corallo commented Dec 11, 2023

Exporting to tflite format fails when the activation function is a leakyReLU / ReLU.

The bug was reported here: #12489
The problem seems to be with the tensorflow version, that has to be <=2.13.1
The other repository (https://github.com/ultralytics/ultralytics) have had a similar patch ultralytics/ultralytics#6466
I am applying the same here to constraint tensorflow version.

copilot:all

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Adjustment to TensorFlow compatibility in YOLOv5 export functionality.

📊 Key Changes

  • Added a version check in export.py to advise on a known issue for TensorFlow versions greater than 2.13.1.
  • Updated the requirements.txt file to restrict TensorFlow version to 2.4.0 or above and up to 2.13.1.

🎯 Purpose & Impact

  • Ensures users are aware of potential problems when exporting models with TensorFlow versions newer than 2.13.1. 🛠️
  • Prevents installation of incompatible TensorFlow versions that could cause export issues, enhancing stability and user experience. 🧰
  • Users running yolov5 exports with TensorFlow will have a smoother experience with controlled version compatibility. ✅

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @Corallo, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

@Corallo Corallo force-pushed the tflite-export-bugfix branch from 1048584 to ad86299 Compare December 11, 2023 18:33
@glenn-jocher
Copy link
Member

@Corallo hi there! Thanks for reporting this issue. We appreciate your diligence in tracking down the root cause and providing a solution. You can limit the TensorFlow version by adding tensorflow<=2.13.1 to your requirements.txt file and perform a version check in your code using tf.__version__ to ensure compatibility. Feel free to visit our Ultralytics Docs for further guidance. Your contribution is valuable to the YOLO community! 🚀

@Corallo
Copy link
Contributor Author

Corallo commented Dec 12, 2023

@glenn-jocher The issue doesn't apply only to my customization, but also to the version you have in ./models/hub/yolov5s-LeakyReLU.yaml
Exporting this version to tflite --int8, as mentioned in the issue, results in a broken network.
This PR fixed the issue with that one too.

@glenn-jocher
Copy link
Member

@Corallo Appreciate your insights! It's great that the fix applies to both customizations and the provided YOLOv5s-LeakyReLU model. Maintaining compatibility across different configurations is crucial. We'll look into updating the default configuration. Thank you for your continued contributions! 👍

@glenn-jocher glenn-jocher merged commit a04b49f into ultralytics:master Dec 16, 2023
@glenn-jocher
Copy link
Member

@Corallo PR merged! Thank you for your contributions.

canh25xp pushed a commit to canh25xp/yolov5 that referenced this pull request Dec 22, 2023
* Limit tensorflow version and add checks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Moving check in export script

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
pleb631 pushed a commit to pleb631/yolov5 that referenced this pull request Jan 6, 2024
* Limit tensorflow version and add checks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Moving check in export script

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants