def __init__(self, cfg, input_shape: Dict[str, ShapeSpec]): super().__init__() # fmt: off self.in_features = cfg.MODEL.FCOS.IN_FEATURES self.fpn_strides = cfg.MODEL.FCOS.FPN_STRIDES self.focal_loss_alpha = cfg.MODEL.FCOS.LOSS_ALPHA self.focal_loss_gamma = cfg.MODEL.FCOS.LOSS_GAMMA self.center_sample = cfg.MODEL.FCOS.CENTER_SAMPLE self.strides = cfg.MODEL.FCOS.FPN_STRIDES self.radius = cfg.MODEL.FCOS.POS_RADIUS self.pre_nms_thresh_train = cfg.MODEL.FCOS.INFERENCE_TH_TRAIN self.pre_nms_thresh_test = cfg.MODEL.FCOS.INFERENCE_TH_TEST self.pre_nms_topk_train = cfg.MODEL.FCOS.PRE_NMS_TOPK_TRAIN self.pre_nms_topk_test = cfg.MODEL.FCOS.PRE_NMS_TOPK_TEST self.nms_thresh = cfg.MODEL.FCOS.NMS_TH self.post_nms_topk_train = cfg.MODEL.FCOS.POST_NMS_TOPK_TRAIN self.post_nms_topk_test = cfg.MODEL.FCOS.POST_NMS_TOPK_TEST self.thresh_with_ctr = cfg.MODEL.FCOS.THRESH_WITH_CTR # fmt: on self.iou_loss = IOULoss(cfg.MODEL.FCOS.LOC_LOSS_TYPE) # generate sizes of interest soi = [] prev_size = -1 for s in cfg.MODEL.FCOS.SIZES_OF_INTEREST: soi.append([prev_size, s]) prev_size = s soi.append([prev_size, INF]) self.sizes_of_interest = soi self.fcos_head = FCOSHead(cfg, [input_shape[f] for f in self.in_features])
def __init__(self, cfg, input_shape: Dict[str, ShapeSpec]): super().__init__() # fmt: off self.cfg = cfg self.in_features = cfg.MODEL.DTInst.IN_FEATURES self.fpn_strides = cfg.MODEL.DTInst.FPN_STRIDES self.focal_loss_alpha = cfg.MODEL.DTInst.LOSS_ALPHA self.focal_loss_gamma = cfg.MODEL.DTInst.LOSS_GAMMA self.center_sample = cfg.MODEL.DTInst.CENTER_SAMPLE self.strides = cfg.MODEL.DTInst.FPN_STRIDES self.radius = cfg.MODEL.DTInst.POS_RADIUS self.pre_nms_thresh_train = cfg.MODEL.DTInst.INFERENCE_TH_TRAIN self.pre_nms_thresh_test = cfg.MODEL.DTInst.INFERENCE_TH_TEST self.pre_nms_topk_train = cfg.MODEL.DTInst.PRE_NMS_TOPK_TRAIN self.pre_nms_topk_test = cfg.MODEL.DTInst.PRE_NMS_TOPK_TEST self.nms_thresh = cfg.MODEL.DTInst.NMS_TH self.post_nms_topk_train = cfg.MODEL.DTInst.POST_NMS_TOPK_TRAIN self.post_nms_topk_test = cfg.MODEL.DTInst.POST_NMS_TOPK_TEST self.thresh_with_ctr = cfg.MODEL.DTInst.THRESH_WITH_CTR self.mask_size = cfg.MODEL.DTInst.MASK_SIZE self.num_codes = cfg.MODEL.DTInst.NUM_CODE self.sparse_alpha = cfg.MODEL.DTInst.MASK_SPARSE_ALPHA self.norm_constant = cfg.MODEL.DTInst.NORMALIZATION_CONSTANT self.bg_constant = cfg.MODEL.DTInst.BACKGROUND_CONSTANT self.dtm_type = cfg.MODEL.DTInst.DTM_TYPE if self.dtm_type == 'standard': self.dict_name = 'Centered_DTM_basis_m{}_n{}_a{:.2f}.npz'.format( self.mask_size, self.num_codes, self.sparse_alpha) elif self.dtm_type == 'reciprocal': self.dict_name = 'Centered_reciprocal_DTM_basis_m{}_n{}_a{:.2f}.npz'.format( self.mask_size, self.num_codes, self.sparse_alpha) elif self.dtm_type == 'complement': self.dict_name = 'Centered_complement_DTM_basis_m{}_n{}_a{:.2f}.npz'.format( self.mask_size, self.num_codes, self.sparse_alpha) elif self.dtm_type == 'other': self.dict_name = 'Centered_other_DTM_basis_m{}_n{}_a{:.2f}_bg{:.2f}_norm{:.2f}.npz'.format( self.mask_size, self.num_codes, self.sparse_alpha, self.bg_constant, self.norm_constant) else: raise NotImplementedError # fmt: on self.iou_loss = IOULoss(cfg.MODEL.DTInst.LOC_LOSS_TYPE) # generate sizes of interest soi = [] prev_size = -1 for s in cfg.MODEL.DTInst.SIZES_OF_INTEREST: soi.append([prev_size, s]) prev_size = s soi.append([prev_size, INF]) self.sizes_of_interest = soi self.DTInst_head = DTInstHead( cfg, [input_shape[f] for f in self.in_features]) self.flag_parameters = cfg.MODEL.DTInst.FLAG_PARAMETERS self.mask_encoding = DistanceTransformEncoding(cfg)
def __init__(self, cfg): super(FCOSOutputs, self).__init__() self.focal_loss_alpha = cfg.MODEL.FCOS.LOSS_ALPHA self.focal_loss_gamma = cfg.MODEL.FCOS.LOSS_GAMMA self.center_sample = cfg.MODEL.FCOS.CENTER_SAMPLE self.radius = cfg.MODEL.FCOS.POS_RADIUS self.pre_nms_thresh_train = cfg.MODEL.FCOS.INFERENCE_TH_TRAIN self.pre_nms_topk_train = cfg.MODEL.FCOS.PRE_NMS_TOPK_TRAIN self.post_nms_topk_train = cfg.MODEL.FCOS.POST_NMS_TOPK_TRAIN self.loc_loss_func = IOULoss(cfg.MODEL.FCOS.LOC_LOSS_TYPE) self.pre_nms_thresh_test = cfg.MODEL.FCOS.INFERENCE_TH_TEST self.pre_nms_topk_test = cfg.MODEL.FCOS.PRE_NMS_TOPK_TEST self.post_nms_topk_test = cfg.MODEL.FCOS.POST_NMS_TOPK_TEST self.nms_thresh = cfg.MODEL.FCOS.NMS_TH self.thresh_with_ctr = cfg.MODEL.FCOS.THRESH_WITH_CTR self.box_quality = cfg.MODEL.FCOS.BOX_QUALITY self.num_classes = cfg.MODEL.FCOS.NUM_CLASSES self.strides = cfg.MODEL.FCOS.FPN_STRIDES # whether target location should be inside mask self.sample_in_mask = cfg.MODEL.EMBEDMASK.SAMPLE_IN_MASK # generate sizes of interest soi = [] prev_size = -1 for s in cfg.MODEL.FCOS.SIZES_OF_INTEREST: soi.append([prev_size, s]) prev_size = s soi.append([prev_size, INF]) self.sizes_of_interest = soi self.loss_normalizer_cls = cfg.MODEL.FCOS.LOSS_NORMALIZER_CLS assert self.loss_normalizer_cls in ("moving_fg", "fg", "all"), \ 'MODEL.FCOS.CLS_LOSS_NORMALIZER can only be "moving_fg", "fg", or "all"' # For an explanation, please refer to # https://github.com/facebookresearch/detectron2/blob/ea8b17914fc9a5b7d82a46ccc72e7cf6272b40e4/detectron2/modeling/meta_arch/retinanet.py#L148 self.moving_num_fg = 100 # initialize with any reasonable #fg that's not too small self.moving_num_fg_momentum = 0.9 self.loss_weight_cls = cfg.MODEL.FCOS.LOSS_WEIGHT_CLS
def __init__(self, cfg, input_shape: Dict[str, ShapeSpec]): super().__init__() # fmt: off self.cfg = cfg self.in_features = cfg.MODEL.SMInst.IN_FEATURES self.fpn_strides = cfg.MODEL.SMInst.FPN_STRIDES self.focal_loss_alpha = cfg.MODEL.SMInst.LOSS_ALPHA self.focal_loss_gamma = cfg.MODEL.SMInst.LOSS_GAMMA self.center_sample = cfg.MODEL.SMInst.CENTER_SAMPLE self.strides = cfg.MODEL.SMInst.FPN_STRIDES self.radius = cfg.MODEL.SMInst.POS_RADIUS self.pre_nms_thresh_train = cfg.MODEL.SMInst.INFERENCE_TH_TRAIN self.pre_nms_thresh_test = cfg.MODEL.SMInst.INFERENCE_TH_TEST self.pre_nms_topk_train = cfg.MODEL.SMInst.PRE_NMS_TOPK_TRAIN self.pre_nms_topk_test = cfg.MODEL.SMInst.PRE_NMS_TOPK_TEST self.nms_thresh = cfg.MODEL.SMInst.NMS_TH self.post_nms_topk_train = cfg.MODEL.SMInst.POST_NMS_TOPK_TRAIN self.post_nms_topk_test = cfg.MODEL.SMInst.POST_NMS_TOPK_TEST self.thresh_with_ctr = cfg.MODEL.SMInst.THRESH_WITH_CTR # self.thresh_with_active = cfg.MODEL.SMInst.THRESH_WITH_ACTIVE # fmt: on self.iou_loss = IOULoss(cfg.MODEL.SMInst.LOC_LOSS_TYPE) # generate sizes of interest soi = [] prev_size = -1 for s in cfg.MODEL.SMInst.SIZES_OF_INTEREST: soi.append([prev_size, s]) prev_size = s soi.append([prev_size, INF]) self.sizes_of_interest = soi self.SMInst_head = SMInstHead( cfg, [input_shape[f] for f in self.in_features]) self.flag_parameters = cfg.MODEL.SMInst.FLAG_PARAMETERS self.mask_encoding = SparseMaskEncoding(cfg)