We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
a question about  segmentation model loading
## ❓ Questions and Help
Why they are different？
### Please note that this issue tracker is not a help form and this issue will be closed.
![image](https://user-images.githubusercontent.com/32593161/106227085-8d5d2000-6223-11eb-9c66-fcb037faac92.png)

We have a set of [listed resources available on the website](https://pytorch.org/resources). Our primary means of support is our discussion forum:

- [Discussion Forum](https://discuss.pytorch.org/)


cc @vfdev-5

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchvision/models/segmentation/segmentation.py`
Content:
```
1 from .._utils import IntermediateLayerGetter
2 from ..utils import load_state_dict_from_url
3 from .. import mobilenetv3
4 from .. import resnet
5 from .deeplabv3 import DeepLabHead, DeepLabV3
6 from .fcn import FCN, FCNHead
7 from .lraspp import LRASPP
8 
9 
10 __all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101',
11            'deeplabv3_mobilenet_v3_large', 'lraspp_mobilenet_v3_large']
12 
13 
14 model_urls = {
15     'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',
16     'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',
17     'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',
18     'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',
19     'deeplabv3_mobilenet_v3_large_coco':
20         'https://download.pytorch.org/models/deeplabv3_mobilenet_v3_large-fc3c493d.pth',
21     'lraspp_mobilenet_v3_large_coco': 'https://download.pytorch.org/models/lraspp_mobilenet_v3_large-d234d4ea.pth',
22 }
23 
24 
25 def _segm_model(name, backbone_name, num_classes, aux, pretrained_backbone=True):
26     if 'resnet' in backbone_name:
27         backbone = resnet.__dict__[backbone_name](
28             pretrained=pretrained_backbone,
29             replace_stride_with_dilation=[False, True, True])
30         out_layer = 'layer4'
31         out_inplanes = 2048
32         aux_layer = 'layer3'
33         aux_inplanes = 1024
34     elif 'mobilenet_v3' in backbone_name:
35         backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features
36 
37         # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.
38         # The first and last blocks are always included because they are the C0 (conv1) and Cn.
39         stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, "_is_cn", False)] + [len(backbone) - 1]
40         out_pos = stage_indices[-1]  # use C5 which has output_stride = 16
41         out_layer = str(out_pos)
42         out_inplanes = backbone[out_pos].out_channels
43         aux_pos = stage_indices[-4]  # use C2 here which has output_stride = 8
44         aux_layer = str(aux_pos)
45         aux_inplanes = backbone[aux_pos].out_channels
46     else:
47         raise NotImplementedError('backbone {} is not supported as of now'.format(backbone_name))
48 
49     return_layers = {out_layer: 'out'}
50     if aux:
51         return_layers[aux_layer] = 'aux'
52     backbone = IntermediateLayerGetter(backbone, return_layers=return_layers)
53 
54     aux_classifier = None
55     if aux:
56         aux_classifier = FCNHead(aux_inplanes, num_classes)
57 
58     model_map = {
59         'deeplabv3': (DeepLabHead, DeepLabV3),
60         'fcn': (FCNHead, FCN),
61     }
62     classifier = model_map[name][0](out_inplanes, num_classes)
63     base_model = model_map[name][1]
64 
65     model = base_model(backbone, classifier, aux_classifier)
66     return model
67 
68 
69 def _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):
70     if pretrained:
71         aux_loss = True
72     model = _segm_model(arch_type, backbone, num_classes, aux_loss, **kwargs)
73     if pretrained:
74         _load_weights(model, arch_type, backbone, progress)
75     return model
76 
77 
78 def _load_weights(model, arch_type, backbone, progress):
79     arch = arch_type + '_' + backbone + '_coco'
80     model_url = model_urls.get(arch, None)
81     if model_url is None:
82         raise NotImplementedError('pretrained {} is not supported as of now'.format(arch))
83     else:
84         state_dict = load_state_dict_from_url(model_url, progress=progress)
85         model.load_state_dict(state_dict)
86 
87 
88 def _segm_lraspp_mobilenetv3(backbone_name, num_classes, pretrained_backbone=True):
89     backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features
90 
91     # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.
92     # The first and last blocks are always included because they are the C0 (conv1) and Cn.
93     stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, "_is_cn", False)] + [len(backbone) - 1]
94     low_pos = stage_indices[-4]  # use C2 here which has output_stride = 8
95     high_pos = stage_indices[-1]  # use C5 which has output_stride = 16
96     low_channels = backbone[low_pos].out_channels
97     high_channels = backbone[high_pos].out_channels
98 
99     backbone = IntermediateLayerGetter(backbone, return_layers={str(low_pos): 'low', str(high_pos): 'high'})
100 
101     model = LRASPP(backbone, low_channels, high_channels, num_classes)
102     return model
103 
104 
105 def fcn_resnet50(pretrained=False, progress=True,
106                  num_classes=21, aux_loss=None, **kwargs):
107     """Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.
108 
109     Args:
110         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
111             contains the same classes as Pascal VOC
112         progress (bool): If True, displays a progress bar of the download to stderr
113         num_classes (int): number of output classes of the model (including the background)
114         aux_loss (bool): If True, it uses an auxiliary loss
115     """
116     return _load_model('fcn', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)
117 
118 
119 def fcn_resnet101(pretrained=False, progress=True,
120                   num_classes=21, aux_loss=None, **kwargs):
121     """Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.
122 
123     Args:
124         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
125             contains the same classes as Pascal VOC
126         progress (bool): If True, displays a progress bar of the download to stderr
127         num_classes (int): number of output classes of the model (including the background)
128         aux_loss (bool): If True, it uses an auxiliary loss
129     """
130     return _load_model('fcn', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)
131 
132 
133 def deeplabv3_resnet50(pretrained=False, progress=True,
134                        num_classes=21, aux_loss=None, **kwargs):
135     """Constructs a DeepLabV3 model with a ResNet-50 backbone.
136 
137     Args:
138         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
139             contains the same classes as Pascal VOC
140         progress (bool): If True, displays a progress bar of the download to stderr
141         num_classes (int): number of output classes of the model (including the background)
142         aux_loss (bool): If True, it uses an auxiliary loss
143     """
144     return _load_model('deeplabv3', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)
145 
146 
147 def deeplabv3_resnet101(pretrained=False, progress=True,
148                         num_classes=21, aux_loss=None, **kwargs):
149     """Constructs a DeepLabV3 model with a ResNet-101 backbone.
150 
151     Args:
152         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
153             contains the same classes as Pascal VOC
154         progress (bool): If True, displays a progress bar of the download to stderr
155         num_classes (int): The number of classes
156         aux_loss (bool): If True, include an auxiliary classifier
157     """
158     return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)
159 
160 
161 def deeplabv3_mobilenet_v3_large(pretrained=False, progress=True,
162                                  num_classes=21, aux_loss=None, **kwargs):
163     """Constructs a DeepLabV3 model with a MobileNetV3-Large backbone.
164 
165     Args:
166         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
167             contains the same classes as Pascal VOC
168         progress (bool): If True, displays a progress bar of the download to stderr
169         num_classes (int): number of output classes of the model (including the background)
170         aux_loss (bool): If True, it uses an auxiliary loss
171     """
172     return _load_model('deeplabv3', 'mobilenet_v3_large', pretrained, progress, num_classes, aux_loss, **kwargs)
173 
174 
175 def lraspp_mobilenet_v3_large(pretrained=False, progress=True, num_classes=21, **kwargs):
176     """Constructs a Lite R-ASPP Network model with a MobileNetV3-Large backbone.
177 
178     Args:
179         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
180             contains the same classes as Pascal VOC
181         progress (bool): If True, displays a progress bar of the download to stderr
182         num_classes (int): number of output classes of the model (including the background)
183     """
184     if kwargs.pop("aux_loss", False):
185         raise NotImplementedError('This model does not use auxiliary loss')
186 
187     backbone_name = 'mobilenet_v3_large'
188     model = _segm_lraspp_mobilenetv3(backbone_name, num_classes, **kwargs)
189 
190     if pretrained:
191         _load_weights(model, 'lraspp', backbone_name, progress)
192 
193     return model
194
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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
@@ -69,6 +69,7 @@
 def _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):
     if pretrained:
         aux_loss = True
+        kwargs["pretrained_backbone"] = False
     model = _segm_model(arch_type, backbone, num_classes, aux_loss, **kwargs)
     if pretrained:
         _load_weights(model, arch_type, backbone, progress)

{"golden_diff": "diff --git a/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py\n--- a/torchvision/models/segmentation/segmentation.py\n+++ b/torchvision/models/segmentation/segmentation.py\n@@ -69,6 +69,7 @@\n def _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):\n     if pretrained:\n         aux_loss = True\n+        kwargs[\"pretrained_backbone\"] = False\n     model = _segm_model(arch_type, backbone, num_classes, aux_loss, **kwargs)\n     if pretrained:\n         _load_weights(model, arch_type, backbone, progress)\n", "issue": "a question about  segmentation model loading\n## \u2753 Questions and Help\r\nWhy they are different\uff1f\r\n### Please note that this issue tracker is not a help form and this issue will be closed.\r\n![image](https://user-images.githubusercontent.com/32593161/106227085-8d5d2000-6223-11eb-9c66-fcb037faac92.png)\r\n\r\nWe have a set of [listed resources available on the website](https://pytorch.org/resources). Our primary means of support is our discussion forum:\r\n\r\n- [Discussion Forum](https://discuss.pytorch.org/)\r\n\n\ncc @vfdev-5\n", "before_files": [{"content": "from .._utils import IntermediateLayerGetter\nfrom ..utils import load_state_dict_from_url\nfrom .. import mobilenetv3\nfrom .. import resnet\nfrom .deeplabv3 import DeepLabHead, DeepLabV3\nfrom .fcn import FCN, FCNHead\nfrom .lraspp import LRASPP\n\n\n__all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101',\n           'deeplabv3_mobilenet_v3_large', 'lraspp_mobilenet_v3_large']\n\n\nmodel_urls = {\n    'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',\n    'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',\n    'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',\n    'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',\n    'deeplabv3_mobilenet_v3_large_coco':\n        'https://download.pytorch.org/models/deeplabv3_mobilenet_v3_large-fc3c493d.pth',\n    'lraspp_mobilenet_v3_large_coco': 'https://download.pytorch.org/models/lraspp_mobilenet_v3_large-d234d4ea.pth',\n}\n\n\ndef _segm_model(name, backbone_name, num_classes, aux, pretrained_backbone=True):\n    if 'resnet' in backbone_name:\n        backbone = resnet.__dict__[backbone_name](\n            pretrained=pretrained_backbone,\n            replace_stride_with_dilation=[False, True, True])\n        out_layer = 'layer4'\n        out_inplanes = 2048\n        aux_layer = 'layer3'\n        aux_inplanes = 1024\n    elif 'mobilenet_v3' in backbone_name:\n        backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features\n\n        # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.\n        # The first and last blocks are always included because they are the C0 (conv1) and Cn.\n        stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, \"_is_cn\", False)] + [len(backbone) - 1]\n        out_pos = stage_indices[-1]  # use C5 which has output_stride = 16\n        out_layer = str(out_pos)\n        out_inplanes = backbone[out_pos].out_channels\n        aux_pos = stage_indices[-4]  # use C2 here which has output_stride = 8\n        aux_layer = str(aux_pos)\n        aux_inplanes = backbone[aux_pos].out_channels\n    else:\n        raise NotImplementedError('backbone {} is not supported as of now'.format(backbone_name))\n\n    return_layers = {out_layer: 'out'}\n    if aux:\n        return_layers[aux_layer] = 'aux'\n    backbone = IntermediateLayerGetter(backbone, return_layers=return_layers)\n\n    aux_classifier = None\n    if aux:\n        aux_classifier = FCNHead(aux_inplanes, num_classes)\n\n    model_map = {\n        'deeplabv3': (DeepLabHead, DeepLabV3),\n        'fcn': (FCNHead, FCN),\n    }\n    classifier = model_map[name][0](out_inplanes, num_classes)\n    base_model = model_map[name][1]\n\n    model = base_model(backbone, classifier, aux_classifier)\n    return model\n\n\ndef _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):\n    if pretrained:\n        aux_loss = True\n    model = _segm_model(arch_type, backbone, num_classes, aux_loss, **kwargs)\n    if pretrained:\n        _load_weights(model, arch_type, backbone, progress)\n    return model\n\n\ndef _load_weights(model, arch_type, backbone, progress):\n    arch = arch_type + '_' + backbone + '_coco'\n    model_url = model_urls.get(arch, None)\n    if model_url is None:\n        raise NotImplementedError('pretrained {} is not supported as of now'.format(arch))\n    else:\n        state_dict = load_state_dict_from_url(model_url, progress=progress)\n        model.load_state_dict(state_dict)\n\n\ndef _segm_lraspp_mobilenetv3(backbone_name, num_classes, pretrained_backbone=True):\n    backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features\n\n    # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.\n    # The first and last blocks are always included because they are the C0 (conv1) and Cn.\n    stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, \"_is_cn\", False)] + [len(backbone) - 1]\n    low_pos = stage_indices[-4]  # use C2 here which has output_stride = 8\n    high_pos = stage_indices[-1]  # use C5 which has output_stride = 16\n    low_channels = backbone[low_pos].out_channels\n    high_channels = backbone[high_pos].out_channels\n\n    backbone = IntermediateLayerGetter(backbone, return_layers={str(low_pos): 'low', str(high_pos): 'high'})\n\n    model = LRASPP(backbone, low_channels, high_channels, num_classes)\n    return model\n\n\ndef fcn_resnet50(pretrained=False, progress=True,\n                 num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('fcn', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef fcn_resnet101(pretrained=False, progress=True,\n                  num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('fcn', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet50(pretrained=False, progress=True,\n                       num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet101(pretrained=False, progress=True,\n                        num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): The number of classes\n        aux_loss (bool): If True, include an auxiliary classifier\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_mobilenet_v3_large(pretrained=False, progress=True,\n                                 num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a MobileNetV3-Large backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('deeplabv3', 'mobilenet_v3_large', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef lraspp_mobilenet_v3_large(pretrained=False, progress=True, num_classes=21, **kwargs):\n    \"\"\"Constructs a Lite R-ASPP Network model with a MobileNetV3-Large backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n    \"\"\"\n    if kwargs.pop(\"aux_loss\", False):\n        raise NotImplementedError('This model does not use auxiliary loss')\n\n    backbone_name = 'mobilenet_v3_large'\n    model = _segm_lraspp_mobilenetv3(backbone_name, num_classes, **kwargs)\n\n    if pretrained:\n        _load_weights(model, 'lraspp', backbone_name, progress)\n\n    return model\n", "path": "torchvision/models/segmentation/segmentation.py"}], "after_files": [{"content": "from .._utils import IntermediateLayerGetter\nfrom ..utils import load_state_dict_from_url\nfrom .. import mobilenetv3\nfrom .. import resnet\nfrom .deeplabv3 import DeepLabHead, DeepLabV3\nfrom .fcn import FCN, FCNHead\nfrom .lraspp import LRASPP\n\n\n__all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101',\n           'deeplabv3_mobilenet_v3_large', 'lraspp_mobilenet_v3_large']\n\n\nmodel_urls = {\n    'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',\n    'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',\n    'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',\n    'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',\n    'deeplabv3_mobilenet_v3_large_coco':\n        'https://download.pytorch.org/models/deeplabv3_mobilenet_v3_large-fc3c493d.pth',\n    'lraspp_mobilenet_v3_large_coco': 'https://download.pytorch.org/models/lraspp_mobilenet_v3_large-d234d4ea.pth',\n}\n\n\ndef _segm_model(name, backbone_name, num_classes, aux, pretrained_backbone=True):\n    if 'resnet' in backbone_name:\n        backbone = resnet.__dict__[backbone_name](\n            pretrained=pretrained_backbone,\n            replace_stride_with_dilation=[False, True, True])\n        out_layer = 'layer4'\n        out_inplanes = 2048\n        aux_layer = 'layer3'\n        aux_inplanes = 1024\n    elif 'mobilenet_v3' in backbone_name:\n        backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features\n\n        # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.\n        # The first and last blocks are always included because they are the C0 (conv1) and Cn.\n        stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, \"_is_cn\", False)] + [len(backbone) - 1]\n        out_pos = stage_indices[-1]  # use C5 which has output_stride = 16\n        out_layer = str(out_pos)\n        out_inplanes = backbone[out_pos].out_channels\n        aux_pos = stage_indices[-4]  # use C2 here which has output_stride = 8\n        aux_layer = str(aux_pos)\n        aux_inplanes = backbone[aux_pos].out_channels\n    else:\n        raise NotImplementedError('backbone {} is not supported as of now'.format(backbone_name))\n\n    return_layers = {out_layer: 'out'}\n    if aux:\n        return_layers[aux_layer] = 'aux'\n    backbone = IntermediateLayerGetter(backbone, return_layers=return_layers)\n\n    aux_classifier = None\n    if aux:\n        aux_classifier = FCNHead(aux_inplanes, num_classes)\n\n    model_map = {\n        'deeplabv3': (DeepLabHead, DeepLabV3),\n        'fcn': (FCNHead, FCN),\n    }\n    classifier = model_map[name][0](out_inplanes, num_classes)\n    base_model = model_map[name][1]\n\n    model = base_model(backbone, classifier, aux_classifier)\n    return model\n\n\ndef _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):\n    if pretrained:\n        aux_loss = True\n        kwargs[\"pretrained_backbone\"] = False\n    model = _segm_model(arch_type, backbone, num_classes, aux_loss, **kwargs)\n    if pretrained:\n        _load_weights(model, arch_type, backbone, progress)\n    return model\n\n\ndef _load_weights(model, arch_type, backbone, progress):\n    arch = arch_type + '_' + backbone + '_coco'\n    model_url = model_urls.get(arch, None)\n    if model_url is None:\n        raise NotImplementedError('pretrained {} is not supported as of now'.format(arch))\n    else:\n        state_dict = load_state_dict_from_url(model_url, progress=progress)\n        model.load_state_dict(state_dict)\n\n\ndef _segm_lraspp_mobilenetv3(backbone_name, num_classes, pretrained_backbone=True):\n    backbone = mobilenetv3.__dict__[backbone_name](pretrained=pretrained_backbone, _dilated=True).features\n\n    # Gather the indices of blocks which are strided. These are the locations of C1, ..., Cn-1 blocks.\n    # The first and last blocks are always included because they are the C0 (conv1) and Cn.\n    stage_indices = [0] + [i for i, b in enumerate(backbone) if getattr(b, \"_is_cn\", False)] + [len(backbone) - 1]\n    low_pos = stage_indices[-4]  # use C2 here which has output_stride = 8\n    high_pos = stage_indices[-1]  # use C5 which has output_stride = 16\n    low_channels = backbone[low_pos].out_channels\n    high_channels = backbone[high_pos].out_channels\n\n    backbone = IntermediateLayerGetter(backbone, return_layers={str(low_pos): 'low', str(high_pos): 'high'})\n\n    model = LRASPP(backbone, low_channels, high_channels, num_classes)\n    return model\n\n\ndef fcn_resnet50(pretrained=False, progress=True,\n                 num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('fcn', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef fcn_resnet101(pretrained=False, progress=True,\n                  num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('fcn', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet50(pretrained=False, progress=True,\n                       num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet101(pretrained=False, progress=True,\n                        num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): The number of classes\n        aux_loss (bool): If True, include an auxiliary classifier\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_mobilenet_v3_large(pretrained=False, progress=True,\n                                 num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a MobileNetV3-Large backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n        aux_loss (bool): If True, it uses an auxiliary loss\n    \"\"\"\n    return _load_model('deeplabv3', 'mobilenet_v3_large', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef lraspp_mobilenet_v3_large(pretrained=False, progress=True, num_classes=21, **kwargs):\n    \"\"\"Constructs a Lite R-ASPP Network model with a MobileNetV3-Large backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n        num_classes (int): number of output classes of the model (including the background)\n    \"\"\"\n    if kwargs.pop(\"aux_loss\", False):\n        raise NotImplementedError('This model does not use auxiliary loss')\n\n    backbone_name = 'mobilenet_v3_large'\n    model = _segm_lraspp_mobilenetv3(backbone_name, num_classes, **kwargs)\n\n    if pretrained:\n        _load_weights(model, 'lraspp', backbone_name, progress)\n\n    return model\n", "path": "torchvision/models/segmentation/segmentation.py"}]}