def __init__(self, dim): super(CrossPooling, self).__init__() self.p1_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p2_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p_conv1 = nn.Conv2D(dim, 3, 1, 1, use_bias=False, in_channels=128) self.p_bn1 = nn.BatchNorm(in_channels=dim) self.conv1 = nn.Conv2D(dim, 1, 1, 0, use_bias=False, in_channels=dim) self.bn1 = nn.BatchNorm(in_channels=dim) self.relu1 = nn.Activation(activation='relu') self.conv2 = BasicConvBlock(dim, 3, 1, 1, use_bias=False, in_c=dim)
def __init__(self, dim, pool1, pool2, pool3, pool4): super(pool_cross, self).__init__() self.p1_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p2_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p_conv1 = nn.Conv2D(dim, 3, 1, 1, use_bias=False, in_channels=128) self.p_bn1 = nn.BatchNorm(in_channels=dim) self.conv1 = nn.Conv2D(dim, 1, 1, 0, use_bias=False, in_channels=dim) self.bn1 = nn.BatchNorm(in_channels=dim) self.relu1 = nn.Activation(activation='relu') self.conv2 = BasicConvBlock(dim, 3, 1, 1, use_bias=False, in_c=dim) self.pool1 = pool1 self.pool2 = pool2 self.pool3 = pool3 self.pool4 = pool4
def __init__(self, dim): super(BottomRightPooling, self).__init__() self.p1_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p2_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.p_conv1 = nn.Conv2D(dim, 3, 1, 1, use_bias=False, in_channels=128) self.p_bn1 = nn.BatchNorm(in_channels=dim) self.conv1 = nn.Conv2D(dim, 1, 1, 0, use_bias=False, in_channels=dim) self.bn1 = nn.BatchNorm(in_channels=dim) self.relu1 = nn.Activation(activation='relu') self.conv2 = BasicConvBlock(dim, 3, 1, 1, use_bias=False, in_c=dim) # self.pool1 = pool1 # Bottom Pooling # self.pool2 = pool2 # Right Pooling self.look_conv1 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.look_conv2 = BasicConvBlock(128, 3, 1, 1, use_bias=False, in_c=dim) self.P1_look_conv = nn.Conv2D(128, 3, 1, 1, use_bias=False, in_channels=128) self.P2_look_conv = nn.Conv2D(128, 3, 1, 1, use_bias=False, in_channels=128)
def __init__(self, backbone, n_cls, **kwargs): ''' CenterNet Backbone: Ghost Neck : Stair Upsampling Head : CenterNet (Cascade Corner Pooling, Center Pooling, Heatmap, Embeding map etc.) @params backbone: str or gluon Modules @params n_cls: class nums, e.g. 80 for coco dataset, 20 for voc ''' super(CenterNetTri, self).__init__(**kwargs) ## backbone with self.name_scope(): ## Stem Block, downscale by 4 total # TODO: add stem block here: BasicConvBlock(128, 7, 2, 3, use_bias=False, in_c=3) & ResConvBlock(256, 3, 2, 1, False, 128) ## Backbone if isinstance(backbone, str): self.backbone = model_zoo.get_model(backbone, **kwargs) else: self.backbone = backbone ## Neck self.neck = StairUpsampling(cout=256, n_stages=3) ## Head self.cnvs = BasicConvBlock(256, 3, 1, 1, False, 256, True, True) self.tl_cnvs = TopLeftPooling(256) # cascade top left pooling self.br_cnvs = BottomRightPooling( 256) # cascade bottom right pooling self.ct_cnvs = CrossPooling(256) # center pooling ## Keypoint heatmaps self.tl_heats = HeatmapConvBlock(n_cls, 256, 3, 1, 1, True, 256) self.br_heats = HeatmapConvBlock(n_cls, 256, 3, 1, 1, True, 256) self.ct_heats = HeatmapConvBlock(n_cls, 256, 3, 1, 1, True, 256) ## Tags, same structure as heatmaps except the output channel nums self.tl_tags = TagConvBlock(1, 256, 3, 1, 1, True, 256) self.br_tags = TagConvBlock(1, 256, 3, 1, 1, True, 256) ## Box Regress, same as tag & heatmap output layers, only different at the output channels self.tl_regs = RegConvBlock(2, 256, 3, 1, 1, True, 256) self.br_regs = RegConvBlock(2, 256, 3, 1, 1, True, 256) self.ct_regs = RegConvBlock(2, 256, 3, 1, 1, True, 256) ## for training self.transpose_gather_feats = TransposeGatherFeats()
def __init__(self, c_out=2, c_mid=256, kernel_size=3, strides=1, padding=1, use_bias=True, in_c=0, **kwargs): super(RegConvBlock, self).__init__(**kwargs) with self.name_scope(): self.conv0 = BasicConvBlock(c_mid, kernel_size, strides, padding, use_bias, in_c, False) self.out = nn.Conv2D(c_out, 1, 1, 0, in_channels=c_mid)