Esempio n. 1
0
    def __init__(self, block, layers, channels, norm_layer=nn.BatchNorm2d):
        super(Xception, self).__init__()

        self.in_channels = 8
        self.conv1 = ConvBnRelu(3,
                                self.in_channels,
                                3,
                                2,
                                1,
                                has_bn=True,
                                norm_layer=norm_layer,
                                has_relu=True,
                                has_bias=False)
        self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)

        self.layer1 = self._make_layer(block,
                                       norm_layer,
                                       layers[0],
                                       channels[0],
                                       stride=2)
        self.layer2 = self._make_layer(block,
                                       norm_layer,
                                       layers[1],
                                       channels[1],
                                       stride=2)
        self.layer3 = self._make_layer(block,
                                       norm_layer,
                                       layers[2],
                                       channels[2],
                                       stride=2)
Esempio n. 2
0
    def __init__(self,
                 in_channels,
                 out_channels,
                 kernel_size=1,
                 stride=1,
                 padding=0,
                 dilation=1,
                 has_relu=True,
                 norm_layer=nn.BatchNorm2d):
        super(SeparableConvBnRelu, self).__init__()

        self.conv1 = nn.Conv2d(in_channels,
                               in_channels,
                               kernel_size,
                               stride,
                               padding,
                               dilation,
                               groups=in_channels,
                               bias=False)
        self.point_wise_cbr = ConvBnRelu(in_channels,
                                         out_channels,
                                         1,
                                         1,
                                         0,
                                         has_bn=True,
                                         norm_layer=norm_layer,
                                         has_relu=has_relu,
                                         has_bias=False)
Esempio n. 3
0
    def __init__(self, name, out_planes, fc_dim=4096, pool_scales=[1, 2, 3, 6],
                 norm_layer=nn.BatchNorm2d):
        super(PyramidPooling, self).__init__()

        self.ppm = []
        for scale in pool_scales:
            self.ppm.append(nn.Sequential(OrderedDict([
                ('{}/pool_1'.format(name), nn.AdaptiveAvgPool2d(scale)),
                ('{}/cbr'.format(name),
                 ConvBnRelu(fc_dim, 512, 1, 1, 0, has_bn=True,
                            has_relu=True, has_bias=False,
                            norm_layer=norm_layer))
            ])))
        self.ppm = nn.ModuleList(self.ppm)

        self.conv6 = nn.Sequential(
            ConvBnRelu(fc_dim + len(pool_scales) * 512, 512, 3, 1, 1,
                       has_bn=True,
                       has_relu=True, has_bias=False, norm_layer=norm_layer),
            nn.Dropout2d(0.1, inplace=False),
            nn.Conv2d(512, out_planes, kernel_size=1)
        )
Esempio n. 4
0
    def __init__(self,
                 out_planes,
                 criterion,
                 pretrained_model=None,
                 norm_layer=nn.BatchNorm2d):
        super(PSPNet, self).__init__()
        self.backbone = backbone[config.model.backbone](
            pretrained_model,
            norm_layer=norm_layer,
            bn_eps=config.model.bn_eps,
            bn_momentum=config.model.bn_momentum,
            deep_stem=config.model.deep_stem,
            stem_width=64)
        self.backbone.layer3.apply(partial(self._nostride_dilate, dilate=2))
        self.backbone.layer4.apply(partial(self._nostride_dilate, dilate=4))

        self.business_layer = []
        self.psp_layer = PyramidPooling('psp',
                                        out_planes,
                                        2048,
                                        norm_layer=norm_layer)
        self.aux_layer = nn.Sequential(
            ConvBnRelu(1024,
                       1024,
                       3,
                       1,
                       1,
                       has_bn=True,
                       has_relu=True,
                       has_bias=False,
                       norm_layer=norm_layer), nn.Dropout2d(0.1,
                                                            inplace=False),
            nn.Conv2d(1024, out_planes, kernel_size=1))
        self.business_layer.append(self.psp_layer)
        self.business_layer.append(self.aux_layer)

        self.criterion = criterion