def __init__(self, priors_cxcy, config, threshold=0.5, neg_pos_ratio=3, theta=0.01): super(RefineDetBofTrafficLoss, self).__init__() self.priors_cxcy = priors_cxcy self.priors_xy = cxcy_to_xy(priors_cxcy) self.threshold = threshold self.neg_pos_ratio = neg_pos_ratio self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes self.config = config self.theta = theta self.arm_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Diou') self.odm_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Diou') self.arm_cross_entropy = nn.CrossEntropyLoss(reduce=False) self.odm_cross_entropy = nn.CrossEntropyLoss(reduce=False)
def __init__(self, priors_cxcy, config, n_candidates=9): super(RetinaATSSNetLoss, self).__init__() self.priors_cxcy = priors_cxcy self.priors_xy = [cxcy_to_xy(prior) for prior in self.priors_cxcy] self.n_candidates = n_candidates self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes - 1 fmap_dims = { 'c3': [64, 64], 'c4': [32, 32], 'c5': [16, 16], 'c6': [8, 8], 'c7': [4, 4] } self.prior_split_points = [0] fmap_keys = ['c3', 'c4', 'c5', 'c6', 'c7'] for k in fmap_keys: self.prior_split_points.append(self.prior_split_points[-1] + fmap_dims[k][0] * fmap_dims[k][1]) self.regression_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Ciou') self.classification_loss = SigmoidFocalLoss(gamma=2.0, alpha=0.25, config=config)
def __init__(self, priors_cxcy, config, threshold=0.5, neg_pos_ratio=3): super(RetinaFocalLoss, self).__init__() self.priors_cxcy = priors_cxcy self.priors_xy = cxcy_to_xy(priors_cxcy) self.threshold = threshold self.neg_pos_ratio = neg_pos_ratio self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes self.config = config self.smooth_l1 = SmoothL1Loss(reduction='mean') self.Diou_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Diou') self.cross_entropy = nn.CrossEntropyLoss(reduce=False) # self.Focal_loss = FocalLoss() self.Focal_loss = focal_loss
def __init__(self, priors_cxcy, config, threshold=0.5, theta=0.1): super(VGGNETNetDetectorLoss, self).__init__() self.priors_cxcy = priors_cxcy self.priors_xy = cxcy_to_xy(priors_cxcy) self.threshold = threshold self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes - 1 self.theta = theta self.regression_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Ciou') self.classification_loss = SigmoidFocalLoss(gamma=2.0, alpha=0.25, config=config)
def __init__(self, priors_cxcy, config, threshold=0.5): super(RetinaFocalLoss, self).__init__() self.priors_cxcy = priors_cxcy self.priors_xy = cxcy_to_xy(priors_cxcy) self.threshold = threshold self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes - 1 self.smooth_l1 = SmoothL1Loss(reduction='mean') self.Diou_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Ciou') self.Focal_loss = SigmoidFocalLoss(gamma=2.0, alpha=0.25, config=config)
def __init__(self, locations, config, threshold=0.5, center_sample=True): super(FCOSLoss, self).__init__() self.threshold = threshold self.alpha = config.reg_weights self.device = config.device self.n_classes = config.n_classes self.config = config self.locations = locations self.center_sample = center_sample self.INF = 1e6 self.Diou_loss = IouLoss(pred_mode='Corner', reduce='mean', losstype='Diou') self.Focal_loss = SigmoidFocalLoss(gamma=2.0, alpha=0.25, config=config) self.center_loss = nn.BCEWithLogitsLoss() self.fpn_strides = [ 8 / 512., 16 / 512., 32 / 512., 64 / 512., 128 / 512. ] self.sizes = [[0., 0.08], [0.08, 0.16], [0.16, 0.32], [0.32, 0.64], [0.64, 1.]] self.radius = 1.5