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 resnet_fpn_backbone docstring, allow backbone to be pluggable #2499

Closed
wants to merge 1 commit into from

Conversation

jimexist
Copy link

@jimexist jimexist commented Jul 22, 2020

this PR addresses two issues:

  1. fix the docstring position for resnet_fpn_backbone
  2. allow resnet_fpn_backbone to be used with compatible backbones other than the list provided in resnet module, e.g. resnext and resnest

the misplaced docstring was added in #2160.

@@ -5,7 +5,6 @@
from torchvision.models.detection.image_list import ImageList
from torchvision.models.detection.transform import GeneralizedRCNNTransform
from torchvision.models.detection.rpn import AnchorGenerator, RPNHead, RegionProposalNetwork
from torchvision.models.detection.backbone_utils import resnet_fpn_backbone
Copy link
Author

Choose a reason for hiding this comment

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

not in use

@jimexist
Copy link
Author

cc @muaz-urwa

@codecov
Copy link

codecov bot commented Jul 22, 2020

Codecov Report

Merging #2499 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2499      +/-   ##
==========================================
+ Coverage   70.60%   70.62%   +0.01%     
==========================================
  Files          94       94              
  Lines        7995     7999       +4     
  Branches     1272     1274       +2     
==========================================
+ Hits         5645     5649       +4     
  Misses       1947     1947              
  Partials      403      403              
Impacted Files Coverage Δ
torchvision/models/detection/backbone_utils.py 100.00% <100.00%> (ø)

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 1aef87d...aad9b50. Read the comment docs.

@jimexist jimexist force-pushed the add-callable-backbone-util branch 2 times, most recently from f42bb0a to e19785e Compare July 22, 2020 09:05
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 for the PR!

The resnet_fpn_backbone has many built-in assumptions about the model structure, and as such is not generic enough to accept a callable in my opinion. The same thing happens btw with IntermediateLayerGetter, and that's the reason why it's under a private namespace.

As such, I think it would be preferable to not move forward with this PR, as I think it can lead to more issues and confusion for the users, and thus I'm closing the PR.

Please let me know if you think otherwise.

if isinstance(backbone, str):
backbone = resnet.__dict__[backbone](pretrained=pretrained, norm_layer=norm_layer)
elif callable(backbone):
backbone = backbone(pretrained=pretrained, norm_layer=norm_layer)
Copy link
Member

Choose a reason for hiding this comment

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

This assumes that the callable has a particular interface and its modules follow the same convention of resnets, which is not always the case and will fail for most of the models in torchvision. As such, I think it might be better to avoid trying to be generic in here, given that this function is not meant to be generic.

@fmassa fmassa closed this Jul 29, 2020
@jimexist jimexist deleted the add-callable-backbone-util branch August 3, 2020 07:27
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.

None yet

2 participants