Skip to content

Feature: box_iou - #1874

Merged
SkalskiP merged 13 commits into
roboflow:developfrom
Ashp116:single-iou
Jul 14, 2025
Merged

SkalskiP merged 13 commits into
roboflow:developfrom
Ashp116:single-iou

Conversation

@Ashp116

@Ashp116 Ashp116 commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

Description

This PR introduces a lightweight function box_iou that efficiently computes the Intersection over Union (IoU) between two individual bounding boxes. The motivation behind this addition is to avoid unnecessary overhead caused by the box_iou_batch function when used in one-to-one comparisons.

While box_iou_batch is suitable for batch operations, it's inefficient for scenarios involving many single-pair IoU computations. In my case, I was building a DAG structure that required repeated one-to-one IoU evaluations, and using the batch function resulted in nearly 2× slower total compute time. The new box_iou function significantly improves performance in such use cases. Refer to #1873 for more details.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

Tested locally by comparing the output of box_iou with box_iou_batch for several individual box pairs to ensure correctness. Also benchmarked performance using timeit and confirmed that box_iou is ~2x faster for many one-to-one evaluations.

Any specific deployment considerations

None.

Docs

  • Docs updated? What were the changes: Added docstring to the new function.

@Ashp116 Ashp116 changed the title ADD: Added box_iou FEATURE: box_iou Jul 11, 2025
@Ashp116 Ashp116 changed the title FEATURE: box_iou Feature: box_iou Jul 11, 2025

@soumik12345 soumik12345 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @Ashp116, thanks for the valuable contribution!
I've left some feedback with respect to the function signature and documentation.

Comment thread supervision/detection/utils.py Resolved
Comment thread supervision/detection/utils.py Resolved
Comment thread supervision/detection/utils.py Resolved
@Ashp116
Ashp116 requested a review from soumik12345 July 12, 2025 18:59
@Ashp116

Ashp116 commented Jul 12, 2025

Copy link
Copy Markdown
Contributor Author

Hi @soumik12345,

Thank you for reviewing the PR. I have addressed the changes requested and updated the docs to display box_iou.

@soumik12345 soumik12345 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @Ashp116, I have one more minor feedback.

@SkalskiP / @onuralpszr can you please take a look at this PR as well?

Comment thread supervision/detection/utils.py Resolved
@SkalskiP
SkalskiP merged commit a192eed into roboflow:develop Jul 14, 2025
@SkalskiP

Copy link
Copy Markdown
Collaborator

Hi @Ashp116, are you on LinkedIn / X? I'd like to mention you in supervision-0.26.0 release post.

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.

3 participants