def __init__(self, nclass, backbone='mobilenet_v2_1_0', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=True, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(FCNMobileNet, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, norm_layer=norm_layer, norm_kwargs=norm_kwargs) with self.name_scope(): self.head = FCNHead(nclass=nclass, in_channels=self.base_channels[3], norm_layer=norm_layer, norm_kwargs=norm_kwargs) if self.aux: self.auxlayer = FCNHead(nclass=nclass, in_channels=self.base_channels[2], norm_layer=norm_layer, norm_kwargs=norm_kwargs)
def __init__(self, nclass, capacity=512, attention=False, drop=.4, norm_layer=nn.BatchNorm, norm_kwargs=None, height=120, width=120): super(_CAHead, self).__init__() self.up_kwargs = {'height': height, 'width': width} self.attention = attention self.gamma = 1.0 height = height // 2 width = width // 2 with self.name_scope(): # Chained Context Aggregation Module self.gp = GlobalFlow(capacity, 2048, norm_layer, norm_kwargs, height=height, width=width) self.cp1 = _ContextFlow(capacity, stride=2, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=height, width=width) self.cp2 = _ContextFlow(capacity, stride=4, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=height, width=width) self.cp3 = _ContextFlow(capacity, stride=8, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=height, width=width) self.cp4 = _ContextFlow(capacity, stride=16, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=height, width=width) if self.attention: self.selection = _FeatureSelection(256, in_channels=capacity, norm_layer=norm_layer, norm_kwargs=norm_kwargs) else: self.proj = ConvBlock(256, 3, 1, 1, in_channels=capacity, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.drop = nn.Dropout(drop) if drop else None # decoder self.decoder = ConvBlock(48, 3, 1, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.conv3x3 = ConvBlock(256, 3, 1, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs) # segmentation head self.seg_head = FCNHead(nclass, norm_layer=norm_layer, norm_kwargs=norm_kwargs)
def __init__(self, nclass, decoder_capacity, input_height, input_width, norm_layer=nn.BatchNorm, norm_kwargs=None): super(_LadderHead, self).__init__() with self.name_scope(): self.conv_c4 = ConvBlock(decoder_capacity, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs, activation='relu') self.fusion_c3 = _LadderFusion(decoder_capacity, input_height // 16, input_width // 16, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion_c2 = _LadderFusion(decoder_capacity, input_height // 8, input_width // 8, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion_c1 = _LadderFusion(decoder_capacity, input_height // 4, input_width // 4, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.seg_head = FCNHead(nclass, decoder_capacity, norm_layer, norm_kwargs, activation='relu')
def __init__(self, nclass, backbone='densnet169', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=False, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(LadderDenseNet, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, norm_layer=norm_layer, norm_kwargs=norm_kwargs) decoder_capacity = 128 with self.name_scope(): self.head = _LadderHead(nclass, decoder_capacity, norm_layer=norm_layer, norm_kwargs=norm_kwargs, input_height=self._up_kwargs['height'], input_width=self._up_kwargs['width']) if self.aux: self.auxlayer = FCNHead(nclass=nclass, in_channels=decoder_capacity, norm_layer=norm_layer, norm_kwargs=norm_kwargs)
def __init__(self, nclass, backbone='xception65', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=True, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(DeepLabv3Plus, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, dilate=True, norm_layer=norm_layer, norm_kwargs=norm_kwargs) with self.name_scope(): self.head = _DeepLabHead(nclass, 2048, norm_layer, norm_kwargs, height=self._up_kwargs['height'] // 4, width=self._up_kwargs['width'] // 4) if self.aux: self.auxlayer = FCNHead(nclass, 728, norm_layer, norm_kwargs)
def __init__(self, nclass, backbone='resnet50', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=False, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(DenseASPP, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, dilate=True, norm_layer=norm_layer, norm_kwargs=norm_kwargs) with self.name_scope(): self.head = _DenseASPPHead(nclass, 2048, norm_layer, norm_kwargs) if self.aux: self.auxlayer = FCNHead(nclass, 1024, norm_layer, norm_kwargs)
def __init__(self, nclass, backbone='resnet50', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=False, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(CANet, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, dilate=True, norm_layer=norm_layer, norm_kwargs=norm_kwargs) with self.name_scope(): self.head = _CAHead(nclass, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=self._up_kwargs['height'] // 4, width=self._up_kwargs['width'] // 4) if self.aux: self.auxlayer = FCNHead(nclass, 1024, norm_layer, norm_kwargs)
def __init__(self, nclass, backbone='resnet18', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=False, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(BiSeNet, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, dilate=False, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.head = _BiSeNetHead(nclass, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=self._up_kwargs['height'] // 8, width=self._up_kwargs['width'] // 8) if self.aux: self.auxlayer = FCNHead(nclass, norm_layer=norm_layer, norm_kwargs=norm_kwargs, drop_out=.0)
def __init__(self, nclass, backbone='resnet50', aux=True, height=None, width=None, base_size=520, crop_size=480, pretrained_base=False, dilate=True, norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs): super(DeepLabv3, self).__init__(nclass, aux, backbone, height, width, base_size, crop_size, pretrained_base, dilate, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.output_stride = 8 if dilate else 32 with self.name_scope(): self.head = _DeepLabHead(nclass, self.base_channels[3], norm_layer, norm_kwargs, height=self._up_kwargs['height'] // self.output_stride, width=self._up_kwargs['width'] // self.output_stride) if self.aux: self.auxlayer = FCNHead(nclass, self.base_channels[2], norm_layer, norm_kwargs)
def __init__(self, nclass, height, width, norm_layer=nn.BatchNorm, norm_kwargs=None): super(_BiSeNetHead, self).__init__() self.up_kwargs = {'height': height, 'width': width} with self.name_scope(): self.spatial_path = _SpatialPath(128, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.global_flow = GlobalFlow(128, in_channels=512, norm_layer=norm_layer, norm_kwargs=norm_kwargs, height=height, width=width) self.refine_c4 = _ARModule(128, in_channels=512, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.refine_c3 = _ARModule(128, in_channels=256, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.proj = ConvBlock(128, 3, 1, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion = _FFModule(256, norm_layer, norm_kwargs, reduction=1) self.seg = FCNHead(nclass, in_channels=256, norm_layer=norm_layer, norm_kwargs=norm_kwargs, drop_out=.0, reduction=4)
def __init__(self, nclass, num_scale=2, height=60, width=60, norm_layer=nn.BatchNorm, norm_kwargs=None): super(_AttentionHead, self).__init__() self.num_scale = num_scale self.up_kwargs = {'height': height, 'width': width} with self.name_scope(): self.seg_head = FCNHead(nclass, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.conv3x3 = ConvBlock(512, 3, 1, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs, activation='relu') self.conv1x1 = nn.Conv2D(num_scale, 1, in_channels=512)
def __init__(self, nclass, input_height, input_width, capacity=128, norm_layer=nn.BatchNorm, norm_kwargs=None): super(_SwiftNetHead, self).__init__() with self.name_scope(): self.conv1x1 = ConvBlock(capacity, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion_32x = _LateralFusion(capacity, input_height // 32, input_width // 32, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion_16x = _LateralFusion(capacity, input_height // 16, input_width // 16, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.fusion_8x = _LateralFusion(capacity, input_height // 8, input_width // 8, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.final = _LateralFusion(capacity, input_height // 4, input_width // 4, True, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.seg_head = FCNHead(nclass, capacity, norm_layer, norm_kwargs, reduction=1)
def __init__(self, nclass, in_channels, norm_layer=nn.BatchNorm, norm_kwargs=None, height=60, width=60): super(_DeepLabHead, self).__init__() self.up_kwargs = {'height': height, 'width': width} with self.name_scope(): self.aspp = ASPP(256, in_channels, norm_layer, norm_kwargs, height // 2, width // 2, atrous_rates=(12, 24, 36)) self.conv_c1 = ConvBlock(48, 3, 1, 1, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.conv3x3 = ConvBlock(256, 3, 1, 1, in_channels=304, norm_layer=norm_layer, norm_kwargs=norm_kwargs) self.drop = nn.Dropout(0.5) self.head = FCNHead(nclass, 256, norm_layer, norm_kwargs, reduction=1)
def __init__(self, nclass, height, width, norm_layer=nn.BatchNorm, norm_kwargs=None, activation='relu'): super(_PyramidHead, self).__init__() with self.name_scope(): self.pool = PyramidPooling(2048, height, width, norm_layer, norm_kwargs, activation, reduction=4) self.seg_head = FCNHead(nclass, 4096, norm_layer, norm_kwargs)
def __init__(self, nclass, in_channels, norm_layer=nn.BatchNorm, norm_kwargs=None): super(_DenseASPPHead, self).__init__() with self.name_scope(): self.dense_aspp = DenseASPPBlock(256, in_channels, norm_layer, norm_kwargs) self.head = FCNHead(nclass, 256, norm_layer, norm_kwargs, reduction=1)
def __init__(self, nclass, in_channels, norm_layer=nn.BatchNorm, norm_kwargs=None, height=60, width=60): super(_DeepLabHead, self).__init__() with self.name_scope(): self.aspp = ASPP(256, in_channels, norm_layer, norm_kwargs, height, width) self.head = FCNHead(nclass, 256, norm_layer, norm_kwargs, reduction=1)