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

TFDetect dynamic anchor count assignment fix #5668

Merged
merged 3 commits into from
Nov 16, 2021

Conversation

nrupatunga
Copy link
Contributor

@nrupatunga nrupatunga commented Nov 16, 2021

  1. Currently the TFDetect layer is hardcoded to 3 anchors. change it to take care of a dynamic number of anchors in the model

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhancement to output tensor reshaping in TensorFlow model wrapper.

📊 Key Changes

  • Modified the reshaping of the output tensor from 3 * ny * nx to self.na * ny * nx.

🎯 Purpose & Impact

  • Purpose: To fix the logic for reshaping the output tensor to correctly reflect the anchor boxes count (self.na) used in the object detection model.
  • Impact: This change ensures accurate output dimensions, which is critical for proper functioning of object detection. It might affect downstream tasks such as object localization and classification performance. Users working with TensorFlow models will have more reliable output, potentially improving the model's overall predictions on image data.

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 @nrupatunga, thank you for submitting a 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with upstream/master. If your PR is behind upstream/master an automatic GitHub actions rebase may be attempted by including the /rebase command in a comment body, or by running the following code, replacing 'feature' with the name of your local branch:
git remote add upstream https://github.com/ultralytics/yolov5.git
git fetch upstream
git checkout feature  # <----- replace 'feature' with local branch name
git merge upstream/master
git push -u origin -f
  • ✅ Verify all 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

@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 16, 2021

@nrupatunga good catch! If we want to use the number of anchors though, we should use the Detect na attribute defined here:

self.na = len(anchors[0]) // 2 # number of anchors

@nrupatunga
Copy link
Contributor Author

@glenn-jocher Oops! missed it altogether. That's a clean change to do. Fixed the changes.

@glenn-jocher glenn-jocher changed the title [tf-export]: exporting with different number of anchors. TFDetect dynamic anchor count assignment Nov 16, 2021
@glenn-jocher glenn-jocher changed the title TFDetect dynamic anchor count assignment TFDetect dynamic anchor count assignment fix Nov 16, 2021
@glenn-jocher glenn-jocher merged commit 0453b75 into ultralytics:master Nov 16, 2021
@glenn-jocher
Copy link
Member

@nrupatunga PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* fix tf.py when anchors not equal to 3

* revert the isort fix

* update the fix to use anchor attribute available already
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