コード例 #1
0
    def __init__(self, in_channels, out_channels, use_se):
        super().__init__()
        assert out_channels % 2 == 0
        channels = out_channels // 2

        self.branch1 = DWConv2d(in_channels,
                                channels,
                                kernel_size=3,
                                stride=2,
                                norm='default',
                                act='default')

        branch2 = [
            Conv2d(in_channels,
                   channels,
                   kernel_size=1,
                   act='default',
                   norm='default'),
            DWConv2d(channels,
                     channels,
                     kernel_size=3,
                     stride=2,
                     norm='default',
                     act='default'),
        ]
        if use_se:
            branch2.append(SELayer(channels, reduction=2))
        self.branch2 = nn.Sequential(*branch2)
コード例 #2
0
    def __init__(self, in_channels, out_channels, kernel_size, activation,
                 use_se):
        super().__init__()
        assert kernel_size in [3, 5, 7]
        mid_channels = out_channels // 2
        output = out_channels - in_channels
        branch_main = [
            Conv2d(in_channels,
                   mid_channels,
                   kernel_size=1,
                   norm='default',
                   act=activation),
            DWConv2d(mid_channels,
                     output,
                     kernel_size=kernel_size,
                     stride=2,
                     norm='default',
                     act=activation),
        ]
        if use_se:
            branch_main.append(SELayer(output, reduction=2))
        self.branch_main = nn.Sequential(*branch_main)

        self.branch_proj = DWConv2d(in_channels,
                                    in_channels,
                                    kernel_size=kernel_size,
                                    stride=2,
                                    norm='default',
                                    act=activation)
コード例 #3
0
 def __init__(self, in_channels, activation, use_se):
     super().__init__()
     channels = in_channels // 2
     branch = [
         DWConv2d(channels, channels, kernel_size=3,
                  norm_layer='default', activation=activation),
         DWConv2d(channels, channels, kernel_size=3,
                  norm_layer='default', activation=activation),
         DWConv2d(channels, channels, kernel_size=3,
                  norm_layer='default', activation=activation),
     ]
     if use_se:
         branch.append(SELayer(channels, reduction=2))
     self.branch = nn.Sequential(*branch)
コード例 #4
0
    def __init__(self, num_anchors, num_classes=2, in_channels=245, f_channels=256):
        super().__init__()
        self.num_classes = num_classes
        self.conv = DWConv2d(
            in_channels, f_channels, kernel_size=5,
            norm='default', act='default')
        self.loc_conv = Conv2d(
            f_channels, num_anchors * 4, kernel_size=1)
        self.cls_conv = Conv2d(
            f_channels, num_anchors * num_classes, kernel_size=1)

        bias_init_constant(self.cls_conv, inverse_sigmoid(0.01))
コード例 #5
0
 def __init__(self, in_channels, use_se):
     super().__init__()
     assert in_channels % 2 == 0
     channels = in_channels // 2
     branch = [
         Conv2d(channels,
                channels,
                kernel_size=1,
                norm='default',
                act='default'),
         DWConv2d(channels,
                  channels,
                  kernel_size=3,
                  norm='default',
                  act='default'),
     ]
     if use_se:
         branch.append(SELayer(channels, reduction=2))
     self.branch = nn.Sequential(*branch)
コード例 #6
0
 def __init__(self, in_channels, kernel_size, activation, use_se):
     super().__init__()
     assert kernel_size in [3, 5, 7]
     channels = in_channels // 2
     branch = [
         Conv2d(channels,
                channels,
                kernel_size=1,
                norm='default',
                act=activation),
         DWConv2d(channels,
                  channels,
                  kernel_size=kernel_size,
                  norm='default',
                  act=activation),
     ]
     if use_se:
         branch.append(SELayer(channels, reduction=2))
     self.branch = nn.Sequential(*branch)