[ERROR] NotImplementedError: Dilation > 1 not supported in BasicBlock

Hi,

I am using the same syntax used to create deeplabv3 with resnet50. However, I changed backbone to resnet34:

def deeplabv3_resnet34(pretrained=False, progress=True,
                       num_classes=21, aux_loss=None, **kwargs):
    """Constructs a DeepLabV3 model with a ResNet-34 backbone.

    Args:
        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
            contains the same classes as Pascal VOC
        progress (bool): If True, displays a progress bar of the download to stderr
    """
    return _load_model('deeplabv3', 'resnet34', pretrained, progress, num_classes, aux_loss, **kwargs)

It gives the next error:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-21-71ba71ca9be2> in <module>
----> 1 model=deeplabv3_resnet34(pretrained=False,num_classes=2)
      2 model.train()

~/Documents/TFG/seg/models/torchvision.py in deeplabv3_resnet34(pretrained, progress, num_classes, aux_loss, **kwargs)
     91         progress (bool): If True, displays a progress bar of the download to stderr
     92     """
---> 93     return _load_model('deeplabv3', 'resnet34', pretrained, progress, num_classes, aux_loss, **kwargs)
     94 
     95 def deeplabv3_resnet50(pretrained=False, progress=True,

~/Documents/TFG/seg/models/torchvision.py in _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs)
     45     if pretrained:
     46         aux_loss = True
---> 47     model = _segm_resnet(arch_type, backbone, num_classes, aux_loss, **kwargs)
     48     if pretrained:
     49         arch = arch_type + '_' + backbone + '_coco'

~/Documents/TFG/seg/models/torchvision.py in _segm_resnet(name, backbone_name, num_classes, aux, pretrained_backbone)
     18     backbone = resnet.__dict__[backbone_name](
     19         pretrained=pretrained_backbone,
---> 20         replace_stride_with_dilation=[False, True, True])
     21 
     22     return_layers = {'layer4': 'out'}

~/anaconda3/envs/seg/lib/python3.7/site-packages/torchvision/models/resnet.py in resnet34(pretrained, progress, **kwargs)
    247     """
    248     return _resnet('resnet34', BasicBlock, [3, 4, 6, 3], pretrained, progress,
--> 249                    **kwargs)
    250 
    251 

~/anaconda3/envs/seg/lib/python3.7/site-packages/torchvision/models/resnet.py in _resnet(arch, block, layers, pretrained, progress, **kwargs)
    218 
    219 def _resnet(arch, block, layers, pretrained, progress, **kwargs):
--> 220     model = ResNet(block, layers, **kwargs)
    221     if pretrained:
    222         state_dict = load_state_dict_from_url(model_urls[arch],

~/anaconda3/envs/seg/lib/python3.7/site-packages/torchvision/models/resnet.py in __init__(self, block, layers, num_classes, zero_init_residual, groups, width_per_group, replace_stride_with_dilation, norm_layer)
    148                                        dilate=replace_stride_with_dilation[0])
    149         self.layer3 = self._make_layer(block, 256, layers[2], stride=2,
--> 150                                        dilate=replace_stride_with_dilation[1])
    151         self.layer4 = self._make_layer(block, 512, layers[3], stride=2,
    152                                        dilate=replace_stride_with_dilation[2])

~/anaconda3/envs/seg/lib/python3.7/site-packages/torchvision/models/resnet.py in _make_layer(self, block, planes, blocks, stride, dilate)
    191             layers.append(block(self.inplanes, planes, groups=self.groups,
    192                                 base_width=self.base_width, dilation=self.dilation,
--> 193                                 norm_layer=norm_layer))
    194 
    195         return nn.Sequential(*layers)

~/anaconda3/envs/seg/lib/python3.7/site-packages/torchvision/models/resnet.py in __init__(self, inplanes, planes, stride, downsample, groups, base_width, dilation, norm_layer)
     45             raise ValueError('BasicBlock only supports groups=1 and base_width=64')
     46         if dilation > 1:
---> 47             raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
     48         # Both self.conv1 and self.downsample layers downsample the input when stride != 1
     49         self.conv1 = conv3x3(inplanes, planes, stride)

NotImplementedError: Dilation > 1 not supported in BasicBlock
1 Like