-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Adds Generalized IOU, Tests for Box Ops #2642
Conversation
@oke-aditya I'm unsubscribing for now. Ping me again when this is ready for review, i.e. not a draft anymore. |
Docs are not added for some of the I added docs for Tested these docs locally. |
For tests, I thought to keep it similar to IoU tests. But I cannot find tests for IoU and I am unsure how and where to add it. |
Hey @oke-aditya, I'm pretty covered right now, so reviewing this will take a while. Sorry for the delay. |
No issues @pmeier 😀 |
Codecov Report
@@ Coverage Diff @@
## master #2642 +/- ##
==========================================
+ Coverage 72.82% 72.87% +0.05%
==========================================
Files 95 95
Lines 8212 8228 +16
Branches 1283 1283
==========================================
+ Hits 5980 5996 +16
Misses 1838 1838
Partials 394 394
Continue to review full report at Codecov.
|
I had to fix this PR due to Merge conflict of my previous PR. Linter failed here. I will fix it. I hope this goes into the next release. We need tests for IoU, gIoU and other box operations. Do let me know if they are needed. Maybe I can add in a separate PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @oke-aditya
Thanks for the PR and sorry for the delay in reviewing!
The way you did it (without re-using box_iou
) seems ok to me.
For the docs I think everything is good now!
For tests, I propose that we cover a couple of known cases, like Generalized IoU between boxes which are the same, boxes that do not overlap at all, etc (like, at least the sign of the boxes should be known).
We can also take the result from the DETR implementation for a couple of pre-defined boxes and compare against our implementation here.
I added tests for For giou they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests, they look great!
I think there is a bug with the implementation, let me know what you think
Ok, so there is small torch issue why the tests are failing. I updated and seem to get correct result as above.
The issue is out is
where Is there any way to compare these two One thing I tried was Strange! implementation is fine now, but tests aren't :( Please let me know how to compare such two tensor elements. |
One way to do it is to use |
Excellent advice. It's a new thing I learnt and will remember for next time too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
* tries adding genaralized_iou * fixes linting * Adds docs for giou, iou and box area * fixes lint * removes docs to fixup in other PR * linter fix * Cleans comments * Adds tests for box area, iou and giou * typo fix for testCase * fixes typo * fixes box area test * fixes implementation * updates tests to tolerance
* tries adding genaralized_iou * fixes linting * Adds docs for giou, iou and box area * fixes lint * removes docs to fixup in other PR * linter fix * Cleans comments * Adds tests for box area, iou and giou * typo fix for testCase * fixes typo * fixes box area test * fixes implementation * updates tests to tolerance
Fixes #2545
As discussed there, Generalized IOU would be a good feature to add.
I have added that.
The reference implementation is from detr as suggested by fmassa.
Detr has a slightly different implementation of
box_iou
from torchvision which is used bygeneralized_iou
.We return
union
andiou
both in detr, whereas we return onlyiou
in torchvision.I thought not to change the API and instead hence did NOT re-use
box_iou
ingeneralized_iou
.This ensures both these functions would return a single tensor parameter.
I did a bit of code duplication which might not be best practice, please let me know if that can be avoided.
I had thought of making a helper function that returns both
iou
andunion
from which we choose in both cases.For adding tests, I could not find any class in
test_ops.py
file for IOU. I could see for NMS etc, I'm unsure where IoU tests are located.Maybe I overlooked or looked at the wrong place. Do let me know where and how the tests should be!
For docs I saw torchvision ops.rst file. But I cannot find docs for IoU. I'm unsure where to add docs.
Let me know where are they needed.
cc: @fmassa @pmeier