Skip to content

Conversation

zhangguanheng66
Copy link
Contributor

@zhangguanheng66 zhangguanheng66 commented Mar 11, 2020

Fix #1957

The boxes should be Tensor[K, 5] or List[Tensor[L, 4]]

@zhangguanheng66 zhangguanheng66 requested a review from fmassa March 11, 2020 22:21
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.

Thanks a lot for the PR @zhangguanheng66 !

I have a couple of comments.

Also, can you add a test for the check_boxes_is_valid in test_ops.py?

elif isinstance(boxes, torch.Tensor):
assert boxes.size(1) == 5, 'The boxes tensor shape is not correct as Tensor[K, 5]'
else:
assert False, 'boxes shape is not correct'
Copy link
Member

Choose a reason for hiding this comment

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

Can we raise a bit more informative error message, like

boxes is expected to be a Tensor[L, 5] or a List[Tensor[K, 4]]

Comment on lines 38 to 45
if isinstance(boxes, list):
for _tensor in boxes:
assert _tensor.size(1) == 4, \
'The shape of the tensor in the boxes list is not correct as List[Tensor[L, 4]]'
elif isinstance(boxes, torch.Tensor):
assert boxes.size(1) == 5, 'The boxes tensor shape is not correct as Tensor[K, 5]'
else:
assert False, 'boxes shape is not correct'
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this block of code is the same for both roi_align and roi_pool (and we should also add it for ps_roi_align and ps_roi_pool. Can you factor it out into a helper function (maybe called check_boxes_is_valid?) and put it in _utils.py, like we did for convert_boxes_to_roi_format?

@fmassa
Copy link
Member

fmassa commented Mar 13, 2020

Thanks for the improvements! Tests are failing, can you have a look?

@fmassa
Copy link
Member

fmassa commented Mar 13, 2020

Most of the test failures are unrelated to this PR (it's a breakage in PyTorch JIT I believe), but there is still one relevant error

self = <test_ops.DeformConvTester testMethod=test_boxes_shape>

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.

Thanks a lot!

@fmassa fmassa merged commit 505cd69 into pytorch:master Mar 13, 2020
fmassa pushed a commit to fmassa/vision-1 that referenced this pull request Jul 8, 2020
* add checkout/assert in roi_pool

* add checkout/assert in roi_align

* move check_roi_boxes_shape func to ops/_utils.py

* add tests

* fix CI

* fix CI

Co-authored-by: Guanheng Zhang <zhangguanheng@devfair0197.h2.fair>
facebook-github-bot pushed a commit that referenced this pull request Jul 9, 2020
Summary:
* add checkout/assert in roi_pool

* add checkout/assert in roi_align

* move check_roi_boxes_shape func to ops/_utils.py

* add tests

* fix CI

* fix CI

Pull Request resolved: #2429

Reviewed By: zhangguanheng66

Differential Revision: D22437763

Pulled By: fmassa

fbshipit-source-id: 78727f3bfe2514e2c193e2b27d9146693fa800b0

Co-authored-by: Guanheng Zhang <zhangguanheng@devfair0197.h2.fair>
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.

Improve error-checking in RoIPool / Align
2 participants