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

Avoid out-of-image class labels #4902

Merged
merged 3 commits into from
Sep 24, 2021
Merged

Conversation

zldrobit
Copy link
Contributor

@zldrobit zldrobit commented Sep 24, 2021

Avoid out-of-image class labels in detection.
Without this PR, labels may be out of the image.
image

In this PR, labels are contained within the image.
image

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved label positioning for object detection annotations in Ultralytics' YOLOv5.

📊 Key Changes

  • Removed redundant font height calculation for drawing text.
  • Adjusted label positioning logic to allow labels to be drawn inside or outside of bounding boxes, depending on available space.
  • Unified label positioning style across both PIL and OpenCV to enhance consistency.

🎯 Purpose & Impact

  • Enhanced Readability: Better placement of labels ensures they do not overlap with other UI elements or go off-screen, enhancing readability.
  • Increased Robustness: By checking if the label fits outside the box before deciding its position, the change provides smarter annotation that could minimize occlusion on small objects or images with limited space.
  • Visual Consistency Across Backends: Whether using PIL or OpenCV for drawing, labels will now follow the same positioning rules, providing a consistent visual experience for end-users.

@glenn-jocher glenn-jocher merged commit ce7fa81 into ultralytics:master Sep 24, 2021
@glenn-jocher
Copy link
Member

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

@glenn-jocher
Copy link
Member

@zldrobit just tested, PR works well!

Screen Shot 2021-09-24 at 9 28 25 AM

CesarBazanAV pushed a commit to CesarBazanAV/yolov5 that referenced this pull request Sep 29, 2021
* Avoid out-of-image class labels

* Update plots.py

* Cleanup

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* Avoid out-of-image class labels

* Update plots.py

* Cleanup

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.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.

None yet

2 participants