def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.opt = opt
def __init__(self, opt): super(MotLoss, self).__init__() self.crit = paddle.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = paddle.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt self.emb_dim = opt.reid_dim self.nID = opt.nID # param_attr = paddle.ParamAttr(initializer=KaimingUniform()) # bound = 1 / math.sqrt(self.emb_dim) # bias_attr = paddle.ParamAttr(initializer=Uniform(-bound, bound)) # self.classifier = nn.Linear(self.emb_dim, self.nID, weight_attr=param_attr, bias_attr=bias_attr) self.classifier = nn.Linear(self.emb_dim, self.nID, bias_attr=True) if opt.id_loss == 'focal': # 一般用不到 # torch.nn.init.normal_(self.classifier.weight, std=0.01) prior_prob = 0.01 bias_value = -math.log((1 - prior_prob) / prior_prob) # torch.nn.init.constant_(self.classifier.bias, bias_value) weight_attr = paddle.framework.ParamAttr(initializer=nn.initializer.Normal(std=0.01)) bias_attr = paddle.framework.ParamAttr(initializer=nn.initializer.Constant(bias_value)) self.classifier = nn.Linear(self.emb_dim, self.nID, weight_attr=weight_attr, bias_attr=bias_attr) self.IDLoss = nn.CrossEntropyLoss(ignore_index=-1) self.emb_scale = math.sqrt(2) * math.log(self.nID - 1) # self.s_det = nn.Parameter(-1.85 * torch.ones(1)) # self.s_id = nn.Parameter(-1.05 * torch.ones(1)) self.s_det = paddle.create_parameter([1], dtype='float32', default_initializer = nn.initializer.Constant(value=-1.85)) self.s_id = paddle.create_parameter([1], dtype='float32', default_initializer = nn.initializer.Constant(value=-1.05))
def __init__(self, opt): super(MotLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = ( RegL1Loss() if opt.reg_loss == "l1" else RegLoss() if opt.reg_loss == "sl1" else None ) self.crit_wh = ( torch.nn.L1Loss(reduction="sum") if opt.dense_wh else NormRegL1Loss() if opt.norm_wh else RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg ) self.opt = opt self.emb_dim = opt.reid_dim self.nID = opt.nID self.classifier = nn.Linear(self.emb_dim, self.nID) self.IDLoss = nn.CrossEntropyLoss(ignore_index=-1) # self.TriLoss = TripletLoss() self.emb_scale = math.sqrt(2) * math.log(self.nID - 1) self.s_det = nn.Parameter(-1.85 * torch.ones(1)) self.s_id = nn.Parameter(-1.05 * torch.ones(1))
def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = RegWeightedL1Loss() if opt.cat_spec_wh else \ torch.nn.L1Loss(reduction='sum') self.opt = opt
def __init__(self, opt): super(PoseLoss, self).__init__() self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() if loss_type == 'dynamic': self.crit = torch.nn.MSELoss() if opt.mse_loss else DynamicLoss() self.crit_reg = RegL1Loss_acc() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg else: self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt, model): super(SaccadedetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(CenterLandmarkLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else nn.L1Loss( reduction='sum') #####Why sum???? self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else RegLoss( ) if opt.reg_loss == 'sl1' else None self.opt = opt
def __init__(self, cfg, local_rank): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = torch.nn.MSELoss() if cfg.LOSS.MSE_LOSS else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not cfg.LOSS.DENSE_HP else \ torch.nn.L1Loss(reduction='sum') self.crit_reg = RegL1Loss() if cfg.LOSS.REG_LOSS == 'l1' else \ RegLoss() if cfg.LOSS.REG_LOSS == 'sl1' else None self.cfg = cfg self.local_rank = local_rank
def __init__(self, opt): super(CtsegLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.crit_seg = SegLoss2() if opt.last_conv == '3x3conv' else SegLoss() self.opt = opt
def __init__(self, opt): super(CtsegLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.crit_mask = DiceLoss(opt.seg_feat_channel) self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt self.loss_domain = torch.nn.CrossEntropyLoss()
def __init__(self, opt): super(CtdetLoss_doublehm, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.crit_reconstruct_img = torch.nn.L1Loss() self.opt = opt self.test_reconstruct_conflict_with_class = True
def __init__(self, opt): super(RodetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.crit_angle = BinRotLoss() if opt.rotate_binloss else RegMSELoss() self.crit_dense_angle = DenseRegL1Loss() if opt.dense_angle else None self.opt = opt
def __init__(self, opt): super(DetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt #self.TriLoss = TripletLoss() self.s_det = nn.Parameter(-1.85 * torch.ones(1))
def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit_seg = torch.nn.BCEWithLogitsLoss( ) # torch.nn.MSELoss() # hughes self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_centerness = FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.crit_scale = torch.nn.SmoothL1Loss(size_average=False) self.opt = opt
def __init__(self, opt): super(CtdetLoss_NFS, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.centerloss = CenterLoss_freeze() # self.crit = torch.nn.MSELoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() self.crit = FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None if opt.mdn: self.crit_wh = None if opt.dense_wh else None if opt.norm_wh else th_mdn_loss_ind else: self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() ###均方误差,l2 loss self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() ### 定义了几种回归损失的形式 self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None ### 定义了几种wh损失函数的形式 self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = FocalLoss() if opt.mdn: self.crit_kp = th_mdn_loss_dense if opt.dense_hp else \ th_mdn_loss_ind else: self.crit_kp = torch.nn.L1Loss(reduction='sum') if opt.dense_hp else \ RegWeightedL1Loss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.opt = opt
def __init__(self, opt): super(CircleLoss, self).__init__() # if opt.mask_focal_loss: self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() # else: # self.crit = FocalLoss_mask() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(MultiKPSLoss, self).__init__() self.crit = FocalLoss() #中心点hp self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None #中心点回归 self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg #宽高回归 self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss( ) #关键点hp self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') #关键点回归 self.opt = opt
def __init__(self, opt): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None ##changed self.crit_view_side = CrossEntropyLossWMask() self.crit_view_front_rear = CrossEntropyLossWMask() self.opt = opt
def __init__(self, opt): super(HoidetLoss, self).__init__() self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg if opt.hard_negative: self.crit_h = FocalLossHardNeg(7) if opt.hm_rel_dcn25_i_casc_match or opt.hm_rel_dcn25_i_match: self.crit_reg_offset = RegL1LossOffset() self.bce = torch.nn.BCELoss() self.opt = opt
def __init__(self, opt): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None self.opt = opt self.loss_dict = {} self.loss_dict['count'] = 0 self.loss_dict['pos_loss'] = 0 self.loss_dict['neg_loss'] = 0 self.loss_dict['neg_loss1'] = 0 self.loss_dict['num_pos'] = 0
def __init__(self, opt): super(CtdetLoss, self).__init__() # 对于2D目标检测,分类损失使用的是Focal Loss. 这里opt.mse_loss默认为False self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() # 对于2D目标检测,回归损失使用的是L1 Loss. 这里opt.reg_loss默认为l1 self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None # 对于2D目标检测,偏移损失使用的L1 Loss. 这里opt.dense_wh默认为False self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg # self.crit = torch.nn.MSELoss() # self.crit_reg = RegL1Loss() # self.crit_wh = torch.nn.L1Loss(reduction='sum') self.opt = opt
def __init__(self, opt): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') # self.t_crit_kp = t_RegWeightedL1Loss() # self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None # self.t_crit_reg = t_RegL1Loss() if opt.reg_loss == 'l1' else \ # t_RegLoss() if opt.reg_loss == 'sl1' else None self.crit_teacher = torch.nn.MSELoss(size_average=True) self.opt = opt
def __init__(self, opt): super(CtdetLoss, self).__init__() # hm loss criteria self.crit = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() # reg loss criteria self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None # size loss criteria self.crit_wh = torch.nn.L1Loss(reduction='sum') if opt.dense_wh else \ NormRegL1Loss() if opt.norm_wh else \ RegWeightedL1Loss() if opt.cat_spec_wh else self.crit_reg self.opt = opt
def __init__(self, opt): super(MultiPoseLoss, self).__init__() self.crit = FocalLoss() self.crit_hm_hp = torch.nn.MSELoss() if opt.mse_loss else FocalLoss() self.crit_kp = RegWeightedL1Loss() if not opt.dense_hp else \ torch.nn.L1Loss(reduction='sum') self.crit_reg = RegL1Loss() if opt.reg_loss == 'l1' else \ RegLoss() if opt.reg_loss == 'sl1' else None # 3d compatibility self.crit = CritAuto(self.crit) self.crit_hm_hp = CritAuto(self.crit_hm_hp) self.crit_kp = CritAuto(self.crit_kp) self.crit_reg = CritAuto(self.crit_reg) self.opt = opt