Ejemplo n.º 1
0
    def __init__(self, **kwargs):
        super(CondInst, self).__init__()
        self.cfg = {**default_cfg, **kwargs}
        self.backbone = getattr(resnet, self.cfg['backbone'])(
            pretrained=self.cfg['pretrained'],
            reduction=self.cfg['reduction'],
            norm_layer=self.cfg['norm_layer'])
        c3, c4, c5 = self.backbone.inner_channels[-3:]
        self.fpn = FPN(c3, c4, c5, out_channel=self.cfg['fpn_channels'])
        self.grids = None
        self.scales = nn.ModuleList(
            [Scale(init_val=1.0) for _ in range(len(self.cfg['strides']))])
        self.cate_control_branch = CateControllerBranch(
            self.cfg['num_cls'],
            self.cfg['fpn_channels'],
            self.cfg['conv_inner_channels'],
            norm_type='GN',
            mask_out_channels=self.cfg['mask_out_channels'])

        self.mask_branch = MaskBranch(
            in_channels=self.cfg['fpn_channels'],
            inner_channels=self.cfg['mask_branch_inner_channels'],
            out_channels=self.cfg['mask_out_channels'])
        self.dynamic_convs = DynamicConv(self.cate_control_branch.weight_nums,
                                         self.cate_control_branch.bias_nums)
Ejemplo n.º 2
0
 def __init__(self, **kwargs):
     self.cfg = {**default_cfg, **kwargs}
     super(RetinaNet, self).__init__()
     self.backbones = getattr(resnet, self.cfg['backbone'])(pretrained=self.cfg['pretrained'])
     c3, c4, c5 = self.backbones.inner_channels
     self.neck = FPN(c3, c4, c5, self.cfg['fpn_channel'])
     self.head = RetinaHead(in_channel=self.cfg['fpn_channel'],
                            inner_channel=self.cfg['fpn_channel'],
                            num_cls=self.cfg['num_cls'],
                            num_convs=self.cfg['head_conv_num'],
                            layer_num=5,
                            anchor_sizes=self.cfg['anchor_sizes'],
                            anchor_scales=self.cfg['anchor_scales'],
                            anchor_ratios=self.cfg['anchor_ratios'],
                            strides=self.cfg['strides'],
                            block_type=self.cfg['block_type'],
                            on_reg=self.cfg['on_reg'])
     self.loss = PAALoss(
         top_k=self.cfg['top_k'],
         alpha=self.cfg['alpha'],
         gamma=self.cfg['gamma'],
         iou_thresh=self.cfg['iou_thresh'],
         iou_loss_weight=self.cfg['iou_loss_weight'],
         reg_loss_weight=self.cfg['reg_loss_weight'],
         iou_type=self.cfg['iou_type'],
         allow_low_quality_matches=self.cfg['allow_low_quality_matches']
     )
Ejemplo n.º 3
0
 def __init__(self,**kwargs):
     self.cfg={**default_cfg,**kwargs}
     super(GFocal, self).__init__()
     self.backbones=getattr(resnet,self.cfg['backbone'])(pretrained=self.cfg['pretrained'])
     c3,c4,c5=self.backbones.inner_channels
     self.neck=FPN(c3,c4,c5,self.cfg['fpn_channel'])
     self.head=GFocalHead(in_channel=self.cfg['fpn_channel'],
                          inner_channel=self.cfg['fpn_channel'],
                          num_cls=self.cfg['num_cls'],
                          num_convs=self.cfg['head_conv_num'],
                          layer_num=5,
                          anchor_sizes=self.cfg['anchor_sizes'],
                          anchor_scales=self.cfg['anchor_scales'],
                          anchor_ratios=self.cfg['anchor_ratios'],
                          strides=self.cfg['strides'],
                          block_type=self.cfg['block_type'],
                          reg_max=self.cfg['reg_max'],
                          subnet_dim=self.cfg['subnet_dim'],
                          m_top_k=self.cfg['m_top_k'],
                          add_mean=self.cfg['add_mean'])
     self.loss = GFocalLoss(
         strides=self.cfg['strides'],
         top_k=self.cfg['top_k'],
         beta=self.cfg['beta'],
         iou_loss_weight=self.cfg['iou_loss_weight'],
         reg_loss_weight=self.cfg['reg_loss_weight'],
         iou_type=self.cfg['iou_type'],
         anchor_num_per_loc=self.head.anchor_nums
     )
Ejemplo n.º 4
0
 def __init__(self, cfg=None):
     super(FasterRCNN, self).__init__()
     if cfg is None:
         cfg = default_model_config
     else:
         cfg = {**default_model_config, **cfg}
     self.backbones = switch_backbones(cfg['backbone'])
     self.neck = FPN(self.backbones.inner_channels, cfg['fpn_out_channels'])
     self.rpn = RPN(cfg)
     self.roi_head = ROIHead(cfg, cfg['num_cls'] + 1)
Ejemplo n.º 5
0
 def __init__(self,
              anchor_sizes=None,
              anchor_scales=None,
              anchor_ratios=None,
              strides=None,
              num_cls=80,
              backbone='resnet50'):
     super(RetinaNet, self).__init__()
     self.backbones = switch_backbones(backbone)
     c3, c4, c5 = self.backbones.inner_channels
     self.neck = FPN(c3, c4, c5, 256)
     self.head = RetinaHead(256, 256, num_cls, 4, 5, anchor_sizes,
                            anchor_scales, anchor_ratios, strides)
Ejemplo n.º 6
0
 def __init__(self,
              layer_limits=None,
              strides=None,
              num_cls=80,
              backbone='resnet50'):
     super(FCOS, self).__init__()
     self.backbones = switch_backbones(backbone)
     c3, c4, c5 = self.backbones.inner_channels
     self.neck = FPN(c3, c4, c5, 256)
     self.head = FCOSHead(256,
                          256,
                          4,
                          num_cls,
                          strides,
                          layer_limits=layer_limits)