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

fix type hints and spelling mistake in generalized_rcnn and poolers #2550

Merged
merged 7 commits into from
Aug 4, 2020
Merged

fix type hints and spelling mistake in generalized_rcnn and poolers #2550

merged 7 commits into from
Aug 4, 2020

Conversation

jiangyinzuo
Copy link
Contributor

@jiangyinzuo jiangyinzuo commented Aug 4, 2020

fix type hints and spelling mistake in generalized_rcnn and poolers

Copy link
Collaborator

@pmeier pmeier left a 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?

Copy link
Collaborator

@pmeier pmeier left a 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
Copy link
Collaborator

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.

Comment on lines 67 to 68
"of shape [N, 4], got {:}.".format(
boxes.shape))
"of shape [N, 4], got {:}.".format(boxes.shape))
Copy link
Collaborator

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.

Copy link
Collaborator

@pmeier pmeier left a 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
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

Merging #2550 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Impacted Files Coverage Δ
torchvision/models/detection/generalized_rcnn.py 88.52% <100.00%> (+0.19%) ⬆️
torchvision/ops/poolers.py 97.05% <100.00%> (+0.02%) ⬆️

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 df6a796...110687b. Read the comment docs.

@jiangyinzuo
Copy link
Contributor Author

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.

@jiangyinzuo jiangyinzuo changed the title fix type hints and move degenerate boxes to a function in generalized_rcnn fix type hints and spelling mistake in generalized_rcnn and poolers Aug 4, 2020
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!

@fmassa fmassa merged commit c2bbefc into pytorch:master Aug 4, 2020
bryant1410 pushed a commit to bryant1410/vision-1 that referenced this pull request Nov 22, 2020
…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
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