Example #1
0
 def _init_layers(self):
     self.relu = nn.ReLU(inplace=True)
     self.cls_convs = nn.ModuleList()
     self.reg_convs = nn.ModuleList()
     for i in range(self.stacked_convs):
         chn = self.in_channels if i == 0 else self.feat_channels
         self.cls_convs.append(
             ConvModule(
                 chn,
                 self.feat_channels,
                 3,
                 stride=1,
                 padding=1,
                 conv_cfg=self.conv_cfg,
                 norm_cfg=self.norm_cfg))
         self.reg_convs.append(
             ConvModule(
                 chn,
                 self.feat_channels,
                 3,
                 stride=1,
                 padding=1,
                 conv_cfg=self.conv_cfg,
                 norm_cfg=self.norm_cfg))
     self.gfl_cls = nn.Conv2d(
         self.feat_channels,
         self.cls_out_channels,
         3,
         padding=1)
     self.gfl_reg = nn.Conv2d(
         self.feat_channels, 4 * (self.reg_max + 1), 3, padding=1)
     self.scales = nn.ModuleList([Scale(1.0) for _ in self.anchor_strides])
Example #2
0
    def _init_layers(self):
        self.cls_convs = nn.ModuleList()
        self.reg_convs = nn.ModuleList()
        for i in range(self.stacked_convs):
            chn = self.in_channels if i == 0 else self.feat_channels
            self.cls_convs.append(
                ConvModule(
                    chn,
                    self.feat_channels,
                    3,
                    stride=1,
                    padding=1,
                    conv_cfg=self.conv_cfg,
                    norm_cfg=self.norm_cfg,
                    bias=self.norm_cfg is None))
            self.reg_convs.append(
                ConvModule(
                    chn,
                    self.feat_channels,
                    3,
                    stride=1,
                    padding=1,
                    conv_cfg=self.conv_cfg,
                    norm_cfg=self.norm_cfg,
                    bias=self.norm_cfg is None))
        self.fcos_cls = nn.Conv2d(
            self.feat_channels, self.cls_out_channels, 3, padding=1)
        self.fcos_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1)
        self.fcos_centerness = nn.Conv2d(self.feat_channels, 1, 3, padding=1)

        self.scales = nn.ModuleList([Scale(1.0) for _ in self.strides])
Example #3
0
    def _init_layers(self):
        """Initialize each of the layers needed."""
        self.cls_convs = nn.ModuleList()
        self.energy_convs = None if not self.split_convs else nn.ModuleList()
        self.reg_convs = nn.ModuleList()

        # Create the stacked convolutions
        for i in range(self.stacked_convs):
            chn = self.in_channels if i == 0 else self.feat_channels

            # Make the different convolution stacks
            self.cls_convs.append(
                ConvModule(chn,
                           self.feat_channels,
                           3,
                           stride=1,
                           padding=1,
                           conv_cfg=self.conv_cfg,
                           norm_cfg=self.norm_cfg,
                           bias=self.norm_cfg is None))
            if self.split_convs:
                self.energy_convs.append(
                    ConvModule(chn,
                               self.feat_channels,
                               3,
                               stride=1,
                               padding=1,
                               conv_cfg=self.conv_cfg,
                               norm_cfg=self.norm_cfg,
                               bias=self.norm_cfg is None))
            self.reg_convs.append(
                ConvModule(chn,
                           self.feat_channels,
                           3,
                           stride=1,
                           padding=1,
                           conv_cfg=self.conv_cfg,
                           norm_cfg=self.norm_cfg,
                           bias=self.norm_cfg is None))

        # Classifier convolution
        self.wfcos_cls = nn.Conv2d(self.feat_channels,
                                   self.cls_out_channels,
                                   3,
                                   padding=1)
        # Bounding box regression convolution
        self.wfcos_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1)
        # Energy map convolution
        self.wfcos_energy = nn.Conv2d(self.feat_channels,
                                      self.max_energy,
                                      1,
                                      padding=0)

        # Scaling factor for the different heads
        self.scales = nn.ModuleList([Scale(1.0) for _ in self.strides])
Example #4
0
    def _init_layers(self):
        self.cls_convs = nn.ModuleList()
        self.reg_convs = nn.ModuleList()
        for i in range(self.stacked_convs-1):
            chn = self.in_channels if i == 0 else self.feat_channels
            self.cls_convs.append(
                ConvModule(
                    chn,
                    self.feat_channels,
                    3,
                    stride=1,
                    padding=1,
                    conv_cfg=self.conv_cfg,
                    norm_cfg=self.norm_cfg,
                    bias=self.norm_cfg is None))
        for i in range(self.stacked_convs):
            chn = self.in_channels if i == 0 else self.feat_channels
            self.reg_convs.append(
                ConvModule(
                    chn,
                    self.feat_channels,
                    3,
                    stride=1,
                    padding=1,
                    conv_cfg=self.conv_cfg,
                    norm_cfg=self.norm_cfg,
                    bias=self.norm_cfg is None))
        self.fcos_cls = nn.Conv2d(
            self.feat_channels, self.cls_out_channels, 3, padding=1)
        self.fcos_reg = nn.Conv2d(self.feat_channels, 4, 3, padding=1)
        self.fcos_centerness = nn.Conv2d(self.feat_channels, 1, 3, padding=1)
        self.scales = nn.ModuleList([Scale(1.0) for _ in self.strides])

        self.nc = 32
        ###########instance##############
        self.feat_align = FeatureAlign(self.feat_channels, self.feat_channels, 3, flag_norm=self.norm_cfg is not None)
        self.sip_cof = nn.Conv2d(self.feat_channels, self.nc*4, 3, padding=1)

        self.sip_mask_lat = nn.Conv2d(512, self.nc, 3, padding=1)
        self.sip_mask_lat0 = nn.Conv2d(768, 512, 1, padding=0)

        if self.rescoring_flag:
            self.convs_scoring = []
            channels = [1, 16, 16, 16, 32, 64, 128]
            for i in range(6):
                in_channels = channels[i]
                out_channels = channels[i + 1]
                stride = 2 if i == 0 else 2
                padding = 0
                self.convs_scoring.append(
                    ConvModule(
                        in_channels, out_channels,
                        3,
                        stride=stride,
                        padding=padding,
                        bias=True))
            self.convs_scoring = nn.Sequential(*self.convs_scoring)
            self.mask_scoring = nn.Conv2d(128, self.num_classes-1, 1)
            for m in self.convs_scoring:
                kaiming_init(m.conv)
            normal_init(self.mask_scoring, std=0.001)

        self.relu = nn.ReLU(inplace=True)
        self.crop_cuda = CropSplit(2)
        self.crop_gt_cuda = CropSplitGt(2)
        self.init_weights()