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

Rewrite generalized_box_iou and box_iou to share code #3382

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

datumbox
Copy link
Contributor

While investigating a numeric overflow at #3371, I noticed that the implementations of generalized_box_iou() and box_iou() duplicate code. A potential fix for the aforementioned issue would require patching the code in multiple places. It would be easier if instead we rewrite it to remove duplicate code.

I'm filing this PR separately in case we choose an alternative fix for the overflow. I think the refactoring is worth it on its own merit.

@codecov
Copy link

codecov bot commented Feb 11, 2021

Codecov Report

Merging #3382 (fb169a6) into master (059b19b) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3382      +/-   ##
==========================================
- Coverage   74.80%   74.79%   -0.01%     
==========================================
  Files         105      105              
  Lines        9716     9714       -2     
  Branches     1561     1561              
==========================================
- Hits         7268     7266       -2     
  Misses       1961     1961              
  Partials      487      487              
Impacted Files Coverage Δ
torchvision/ops/boxes.py 87.05% <100.00%> (-0.30%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 059b19b...fb169a6. Read the comment docs.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

This is btw what I had done in DETR in https://github.com/facebookresearch/detr/blob/a54b77800eb8e64e3ad0d8237789fcbf2f8350c5/util/box_ops.py#L24-L61, thanks for doing this!

@fmassa fmassa merged commit 51500c7 into pytorch:master Feb 11, 2021
@datumbox datumbox deleted the refactoring/box_iou branch February 11, 2021 17:57
facebook-github-bot pushed a commit that referenced this pull request Feb 12, 2021
Reviewed By: mthrok

Differential Revision: D26422440

fbshipit-source-id: bef833fa6a3dfd546897b1d81da3f2abaa54e0eb
@datumbox datumbox added the bug label Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants