def __init__(self, cfg): # self.cls_loss_func = SigmoidFocalLoss( # cfg.MODEL.LOC.LOSS_GAMMA, # cfg.MODEL.LOC.LOSS_ALPHA # ) cls_loss_name = cfg.MODEL.LOC.CLS_LOSS self.cls_divide_pos_num = True if cls_loss_name == 'fixed_focal_loss': self.cls_loss_func = FixSigmoidFocalLoss(cfg.MODEL.LOC.LOSS_GAMMA, cfg.MODEL.LOC.LOSS_ALPHA) elif cls_loss_name == 'L2': self.cls_loss_func = L2LossWithLogit() elif cls_loss_name == 'GHMC': self.cls_loss_func = GHMC( bins=cfg.MODEL.LOC.LOSS_GHMC_BINS, alpha=cfg.MODEL.LOC.LOSS_GHMC_ALPHA, momentum=cfg.MODEL.LOC.LOSS_GHMC_MOMENTUM) self.cls_divide_pos_num = False # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() if cfg.MODEL.LOC.TARGET_GENERATOR == 'fcos' and cfg.MODEL.LOC.FCOS_CENTERNESS: self.centerness_loss_func = nn.BCEWithLogitsLoss() self.prepare_targets = build_target_generator(cfg) self.cls_loss_weight = cfg.MODEL.LOC.CLS_WEIGHT self.centerness_weight_reg = cfg.MODEL.LOC.TARGET_GENERATOR == 'fcos' and cfg.MODEL.LOC.FCOS_CENTERNESS_WEIGHT_REG self.debug_vis_labels = cfg.MODEL.LOC.DEBUG.VIS_LABELS self.cls_divide_pos_sum = cfg.MODEL.LOC.DIVIDE_POS_SUM if self.cls_divide_pos_sum: self.cls_divide_pos_num = False
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.centerness_loss_func = nn.BCEWithLogitsLoss()
def __init__(self, gamma, alpha, stripe_width=32): self.cls_loss_func = SigmoidFocalLoss(gamma, alpha) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.centerness_loss_func = nn.BCEWithLogitsLoss() self.stripe_width = stripe_width
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss([cfg.MODEL.AVOD.LOSS_GAMMA], [cfg.MODEL.AVOD.LOSS_ALPHA]) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.point_reg_loss_func = nn.L1Loss() self.confidance_loss_func = nn.BCEWithLogitsLoss()
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.centerness_loss_func = nn.BCEWithLogitsLoss() self.vis_labels = cfg.MODEL.FCOS.DEBUG.VIS_LABELS self.object_sizes_of_interest = cfg.MODEL.FCOS.OBJECT_SIZES
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) self.fpn_strides = cfg.MODEL.FCOS.FPN_STRIDES self.center_sampling_radius = cfg.MODEL.FCOS.CENTER_SAMPLING_RADIUS self.iou_loss_type = cfg.MODEL.FCOS.IOU_LOSS_TYPE self.norm_reg_targets = cfg.MODEL.FCOS.NORM_REG_TARGETS # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss(self.iou_loss_type) self.centerness_loss_func = nn.BCEWithLogitsLoss(reduction="sum")
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) self.center_sample = cfg.MODEL.FCOS.CENTER_SAMPLE self.strides = cfg.MODEL.FCOS.FPN_STRIDES self.radius = cfg.MODEL.FCOS.POS_RADIUS self.loc_loss_type = cfg.MODEL.FCOS.LOC_LOSS_TYPE # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss(self.loc_loss_type) self.centerness_loss_func = nn.BCEWithLogitsLoss() self.dense_points = cfg.MODEL.FCOS.DENSE_POINTS
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.centerness_loss_func = nn.BCEWithLogitsLoss() self.cascade_area_th = cfg.MODEL.FCOS.CASCADE_AREA_TH self.vis_labels = cfg.MODEL.FCOS.DEBUG.VIS_LABELS self.no_match_gt_count = { pos_area: 0 for pos_area in self.cascade_area_th }
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.centerness_loss_func = nn.BCEWithLogitsLoss() # 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.object_sizes_of_interest = soi
def __init__(self, cfg): if cfg.LOSS.FOCAL_LOSS == 'SIGMOID': self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) elif cfg.LOSS.FOCAL_LOSS == 'SOFTMAX': self.cls_loss_func = SoftmaxFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) else: raise Exception('no focal loss type named {}'.format( cfg.LOSS.FOCAL_LOSS)) self.center_sample = cfg.MODEL.FCOS.CENTER_SAMPLE self.strides = cfg.MODEL.FCOS.FPN_STRIDES self.radius = cfg.MODEL.FCOS.POS_RADIUS self.loc_loss_type = cfg.MODEL.FCOS.LOC_LOSS_TYPE # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss(self.loc_loss_type) self.centerness_loss_func = nn.BCEWithLogitsLoss() self.dense_points = cfg.MODEL.FCOS.DENSE_POINTS
def __init__(self, cfg): self.cls_loss_func = SigmoidFocalLoss(cfg.MODEL.FCOS.LOSS_GAMMA, cfg.MODEL.FCOS.LOSS_ALPHA) self.use_p2 = cfg.MODEL.BACKBONE.USE_P2 # pdb.set_trace() # (Pdb) cfg.MODEL.FCOS.LOSS_GAMMA # 2.0 # (Pdb) cfg.MODEL.FCOS.LOSS_ALPHA # 0.25 self.center_sample = cfg.MODEL.FCOS.CENTER_SAMPLE if self.use_p2: self.strides = cfg.MODEL.FCOS.FPN_STRIDES_ADDP2 else: self.strides = cfg.MODEL.FCOS.FPN_STRIDES self.radius = cfg.MODEL.FCOS.POS_RADIUS self.loc_loss_type = cfg.MODEL.FCOS.LOC_LOSS_TYPE # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss(self.loc_loss_type) self.centerness_loss_func = nn.BCEWithLogitsLoss()
def __init__(self, cfg): # we make use of IOU Loss for bounding boxes regression, # but we found that L1 in log scale can yield a similar performance self.box_reg_loss_func = IOULoss() self.scale = cfg.MODEL.SCALE