encoding.dilated

We provide correct dilated pre-trained ResNet and DenseNet (stride of 8) for semantic segmentation. For dilation of DenseNet, we provide encoding.nn.DilatedAvgPool2d. All provided models have been verified.

Note

This code is provided together with the paper

  • Hang Zhang, Kristin Dana, Jianping Shi, Zhongyue Zhang, Xiaogang Wang, Ambrish Tyagi, Amit Agrawal. “Context Encoding for Semantic Segmentation” The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2018

Dilated ResNet and DenseNet

ResNet

ResNet

class encoding.dilated.ResNet(block, layers, num_classes=1000, dilated=True, norm_layer=<class 'torch.nn.modules.batchnorm.BatchNorm2d'>)[source]

Dilated Pre-trained ResNet Model, which preduces the stride of 8 featuremaps at conv5.

Parameters:
  • block (Block) – Class for the residual block. Options are BasicBlockV1, BottleneckV1.
  • layers (list of python:int) – Numbers of layers in each block
  • classes (int, default 1000) – Number of classification classes.
  • dilated (bool, default False) – Applying dilation strategy to pretrained ResNet yielding a stride-8 model, typically used in Semantic Segmentation.
  • norm_layer (object) – Normalization layer used in backbone network (default: mxnet.gluon.nn.BatchNorm; for Synchronized Cross-GPU BachNormalization).
  • Reference
    • He, Kaiming, et al. “Deep residual learning for image recognition.” Proceedings of the IEEE conference on computer vision and pattern recognition. 2016.
    • Yu, Fisher, and Vladlen Koltun. “Multi-scale context aggregation by dilated convolutions.”

resnet18

encoding.dilated.resnet18(pretrained=False, **kwargs)[source]

Constructs a ResNet-18 model.

Parameters:pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet34

encoding.dilated.resnet34(pretrained=False, **kwargs)[source]

Constructs a ResNet-34 model.

Parameters:pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet50

encoding.dilated.resnet50(pretrained=False, root='~/.encoding/models', **kwargs)[source]

Constructs a ResNet-50 model.

Parameters:pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet101

encoding.dilated.resnet101(pretrained=False, root='~/.encoding/models', **kwargs)[source]

Constructs a ResNet-101 model.

Parameters:pretrained (bool) – If True, returns a model pre-trained on ImageNet

resnet152

encoding.dilated.resnet152(pretrained=False, root='~/.encoding/models', **kwargs)[source]

Constructs a ResNet-152 model.

Parameters:pretrained (bool) – If True, returns a model pre-trained on ImageNet