-
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
fix type hints and spelling mistake in generalized_rcnn and poolers #2550
Conversation
….models.detection.generalized_rcnn
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 @ChiangYintso and thanks for the PR! The test failures are relevant:
test/test_models.py:186: in _test_detection_model
scripted_model = torch.jit.script(model)
env/lib/python3.6/site-packages/torch/jit/_script.py:888: in script
obj, torch.jit._recursive.infer_methods_to_compile
env/lib/python3.6/site-packages/torch/jit/_recursive.py:317: in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
env/lib/python3.6/site-packages/torch/jit/_recursive.py:376: in create_script_module_impl
create_methods_from_stubs(concrete_type, stubs)
env/lib/python3.6/site-packages/torch/jit/_recursive.py:292: in create_methods_from_stubs
concrete_type._create_methods(defs, rcbs, defaults)
env/lib/python3.6/site-packages/torch/jit/_recursive.py:596: in try_compile_fn
return torch.jit.script(fn, _rcb=rcb)
E RuntimeError:
E Unsupported operation: indexing tensor with unsupported index type 'str'. Only ints, slices, lists and tensors are supported:
E File "/root/project/torchvision/models/detection/generalized_rcnn.py", line 17
E def _check_for_degenerate_boxes(targets):
E for target_idx, target in enumerate(targets):
E boxes = target["boxes"]
E ~~~~~~~~~ <--- HERE
E degenerate_boxes = boxes[:, 2:] <= boxes[:, :2]
E if degenerate_boxes.any():
E '_check_for_degenerate_boxes' is being compiled since it was called from 'KeypointRCNN.forward'
E File "/root/project/torchvision/models/detection/generalized_rcnn.py", line 96
E # Check for degenerate boxes
E if targets is not None:
E _check_for_degenerate_boxes(targets)
E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
E
E features = self.backbone(images.tensors)
Also you seem to have included some unrelated changes (sorting of the imports
, ...). Could you please revert them?
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.
Two more unrelated changes. Otherwise LGTM!
assert trainable_backbone_layers <= 5 and trainable_backbone_layers >= 0 | ||
assert 0 <= trainable_backbone_layers <= 5 |
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.
I understand why you would want to fix this and I'm not opposed to it in general. But this is out of scope for this PR. If you want to make that change we are happy to accept a follow-up PR after this one is merged.
"of shape [N, 4], got {:}.".format( | ||
boxes.shape)) | ||
"of shape [N, 4], got {:}.".format(boxes.shape)) |
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.
This seems like formatting only. Please revert.
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.
I didn't see the test failures. This still has to be addressed.
Codecov Report
@@ Coverage Diff @@
## master #2550 +/- ##
=======================================
Coverage 70.73% 70.73%
=======================================
Files 94 94
Lines 8029 8031 +2
Branches 1275 1275
=======================================
+ Hits 5679 5681 +2
Misses 1946 1946
Partials 404 404
Continue to review full report at Codecov.
|
Thanks for pointing out the test failures and unrelated changes. The failures may be related to torchscript, finally I think it is unnecessary to move the procedure to a function. |
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!
…ytorch#2550) * fix type hints and move degenerate boxes to a function in torchvision.models.detection.generalized_rcnn * format code * format code * changed to static method * revert imports * changed to method * revert procedure for degenerating boxes
fix type hints and spelling mistake in generalized_rcnn and poolers