Repository: pytorch/vision

Issue:
a little problem when using some pretrained models
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
A little problem.

I used some pretrained models to do object detection. 

However, when i used models whose name include others models' name, such as 'fasterrcnn_mobilenet_v3_large_320_fpn', (its name includes the name of model 'mobilenet_v3_large'),  it will download the weight file of the short name models. 

For example, when i used model 'fasterrcnn_mobilenet_v3_large_320_fpn', whenever the pretrained attribute is True or not, the weight file of model 'mobilenet_v3_large' will be downloaded.  

This problem also happen in the models such as 'maskrcnn_resnet50_fpn' and many other models.

## To Reproduce

Steps to reproduce the behavior:
it's easy to reproduce. For example:
```bash
from torchvision.models.detection import *
model = fasterrcnn_mobilenet_v3_large_320_fpn()
```
excute the code above, the weight file of model "mobilenet_v3_large" will be  downloaded.
you can change the model name to other this kind of model names.
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->




cc @fmassa @vfdev-5 @pmeier


Discussion:
@ZhiyanWXZ you can pass `pretrained_backbone=False` and `pretrained=False` to skip any pretrained weights downloading
@datumbox maybe we should only download the backbone weights if `pretrained=False` and `pretrained_backbone=True`?
@ZhiyanWXZ the vast majority of the models have `pretrained=False` and `pretrained_backbone=True` as default parameters which means this is an expected behaviour. As @vfdev-5 said, if you pass `pretrained_backbone=False` it won't download the backbone data.

As for when `pretrained=True` as far as I can tell the `pretrained_backbone` is set to False automatically for all models. Which version of TorchVision are you using?

fasterrcnn_mobilenet_v3_large_fpn/fasterrcnn_mobilenet_v3_large_320_fpn:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/faster_rcnn.py#L382-L383

fasterrcnn_resnet50_fpn:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/faster_rcnn.py#L364-L366

keypointrcnn_resnet50_fpn:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/keypoint_rcnn.py#L334-L336

maskrcnn_resnet50_fpn:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/mask_rcnn.py#L327-L329

retinanet_resnet50_fpn:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/retinanet.py#L616-L618

ssd300_vgg16:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/ssd.py#L574-L576

ssdlite320_mobilenet_v3_large:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/detection/ssdlite.py#L193-L194

fcn_resnet50/fcn_resnet101/deeplabv3_resnet50/deeplabv3_resnet101/deeplabv3_mobilenet_v3_large:
https://github.com/pytorch/vision/blob/183a722169421c83638e68ee2d8fc5bd3415c4b4/torchvision/models/segmentation/segmentation.py#L70-L72

The only problematic case I found was for lraspp_mobilenet_v3_large which I'll patch in a bit.


Resolving patch:
diff --git a/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py
--- a/torchvision/models/segmentation/segmentation.py
+++ b/torchvision/models/segmentation/segmentation.py
@@ -186,6 +186,8 @@ def lraspp_mobilenet_v3_large(pretrained=False, progress=True, num_classes=21, *
         raise NotImplementedError('This model does not use auxiliary loss')
 
     backbone_name = 'mobilenet_v3_large'
+    if pretrained:
+        kwargs["pretrained_backbone"] = False
     model = _segm_lraspp_mobilenetv3(backbone_name, num_classes, **kwargs)
 
     if pretrained:


Test patch: