Пример #1
0
    def __init__(self, in_channels, out_channels, kernel_size=1,
                 padding=1, stride=1, use_dcn=0, num_convs=1):
        super(ConvBlockSeq, self).__init__()

        if isinstance(kernel_size, int):
            kernel_size = [kernel_size]*num_convs
        else:
            num_convs = len(kernel_size)

        if isinstance(padding, int):
            padding = [padding]*num_convs

        if isinstance(stride, int):
            stride = [stride]*num_convs

        if isinstance(use_dcn, (int, bool)):
            use_dcn = [use_dcn]*num_convs

        channels1 = [in_channels] + [out_channels]*(num_convs-1)
        channels2 = [out_channels]*num_convs

        self.conv_blocks = nn.Sequential(*[
            ConvBlock(c1, c2, k, p, s, dcn)
            for c1, c2, k, p, s, dcn in zip(channels1, channels2, kernel_size, padding, stride, use_dcn)
        ])
Пример #2
0
    def __init__(self, in_channels, m, n):
        super(MontageFeatLayer1234, self).__init__()

        self.feat_expasions = nn.ModuleList([NoopLayer()] * m + [
            ConvBlock(
                in_channels, in_channels, kernel_size=3, stride=1, padding=1)
            for _ in range(n)
        ])
Пример #3
0
    def __init__(self, cfg, in_channels):
        super(FEModule, self).__init__()

        num_convs = cfg.MODEL.RETINAPACK.FE.NUM_CONVS
        self.out_channels = cfg.MODEL.RETINAPACK.FE.OUT_CHANNELS
        self.reduction = ConvBlock(in_channels,
                                   self.out_channels,
                                   kernel_size=1,
                                   stride=1,
                                   padding=0)
        self.conv_blocks = nn.ModuleList([
            ConvBlock(self.out_channels,
                      self.out_channels,
                      kernel_size=3,
                      use_dcn=False,
                      use_gn=True,
                      stride=1,
                      padding=1,
                      use_act=True) for _ in range(num_convs)
        ])
Пример #4
0
 def __init__(self, in_channels, m, n):
     super(MontageFeatLayer567_3x3conv, self).__init__()
     module_list = [NoopLayer()] * m
     for i in range(n):
         module_list.extend([
             NoopLayer(),
             ConvBlock(in_channels,
                       in_channels,
                       kernel_size=3,
                       stride=1,
                       padding=1),
             ConvBlock(in_channels,
                       in_channels,
                       kernel_size=3,
                       stride=1,
                       padding=1),
         ])
     module_list.append(
         ConvBlock(in_channels,
                   in_channels,
                   kernel_size=3,
                   stride=1,
                   padding=1))
     self.feat_expasions = nn.ModuleList(module_list)
Пример #5
0
    def __init__(self, in_channels, levels, mode):
        super(MontageFeatLayer, self).__init__()
        self.mode = mode
        self.levels = levels
        assert mode in ['recursive', 'separate']

        uniques, scales_cnt = torch.unique(torch.tensor(levels).int(),
                                           sorted=True,
                                           return_counts=True)

        for i, n in zip(uniques, scales_cnt):
            for j in range(n):
                if j == 0:
                    layer = NoopLayer()
                else:
                    layer = ConvBlock(in_channels,
                                      in_channels,
                                      kernel_size=3,
                                      stride=1,
                                      padding=1)
                setattr(self, "mf_s%d_%d" % (i, j), layer)

        print(self)