Skip to content

Limit detections without explicit if condition#10502

Merged
glenn-jocher merged 5 commits intoultralytics:masterfrom
developer0hye:patch-12
Dec 18, 2022
Merged

Limit detections without explicit if condition#10502
glenn-jocher merged 5 commits intoultralytics:masterfrom
developer0hye:patch-12

Conversation

@developer0hye
Copy link
Copy Markdown
Contributor

@developer0hye developer0hye commented Dec 15, 2022

Signed-off-by: Yonghye Kwon developer.0hye@gmail.com

image

min is slightly faster than if on average-case .

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Refinement of non-max suppression in YOLOv5.

📊 Key Changes

  • Simplified the detection limiting code in the non-max suppression function.

🎯 Purpose & Impact

  • Purpose: To streamline the execution of the non-max suppression by removing redundant condition checks.
  • Impact: This change potentially improves the performance of the model by reducing the computational overhead. It will also make the codebase easier to maintain since there is less complexity in the logic. Users might experience slightly faster inference times and a cleaner code structure. 🚀

developer0hye and others added 2 commits December 15, 2022 11:28
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@glenn-jocher glenn-jocher changed the title limit detections without explicit if condition Limit detections without explicit if condition Dec 17, 2022
@glenn-jocher
Copy link
Copy Markdown
Member

glenn-jocher commented Dec 17, 2022

@developer0hye interesting! What if we just do this? Can you add it to your profiling results? I tested it and it keeps tensor shape the same if dimension exceeds max_det.

-        if i.shape[0] > max_det:  # limit detections
-            i = i[:max_det]
+        i = i[:max_det]  # limit detections

@developer0hye
Copy link
Copy Markdown
Contributor Author

@glenn-jocher

It seems that we don't need explicit processing for this case!

When I test this code with pretrained YOLOv5s on COCO datset, mAP is computed without any issues!

image

developer0hye added a commit to developer0hye/yolov5 that referenced this pull request Dec 17, 2022
@glenn-jocher glenn-jocher merged commit 2c35c1b into ultralytics:master Dec 18, 2022
@glenn-jocher
Copy link
Copy Markdown
Member

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

@developer0hye developer0hye deleted the patch-12 branch December 18, 2022 12:05
glenn-jocher added a commit that referenced this pull request Dec 19, 2022
* sort by confidence and remove excess boxes without explicit if

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* cleanup indexing boxes for remove excess boxes

it is related to #10502.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
00Monkoo pushed a commit to 00Monkoo/cam_test that referenced this pull request Aug 26, 2025
* sort by confidence and remove excess boxes without explicit if

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* cleanup indexing boxes for remove excess boxes

it is related to ultralytics/yolov5#10502.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
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.

2 participants