def __init__(self, alpha=0.25, gamma=2.0, lambda_p=5.0, temperature=1. / 3, strides=None, iou_type='giou'): self.alpha = alpha self.gamma = gamma self.lambda_p = lambda_p self.temperature = temperature if strides is None: strides = [8, 16, 32, 64, 128] self.strides = strides self.box_coder = BoxCoder() self.iou_loss_func = IOULoss(iou_type=iou_type, coord_type='ltrb')
def __init__(self, radius=1, strides=None, layer_limits=None): self.radius = radius # decide matching method self.box_coder = BoxCoder() if strides is None: strides = [8, 16, 32, 64, 128] self.strides = torch.tensor(strides) if layer_limits is None: layer_limits = [64, 128, 256, 512] expand_limits = np.array(layer_limits)[None].repeat( 2).tolist() # list, len=8 ''' FCOS通过规定每一层预测的尺度范围来避免一个sample匹配到多个target的情况 self.layer_limits=[ [-1,64], shape=[5,2] [64,128], [128,256], [256,512], [512,inf]] ''' self.layer_limits = torch.tensor([-1.] + expand_limits + [INF]).view( -1, 2)
def __init__(self, alpha=0.25, gamma=2.0, lambda_p=5.0, temperature=1. / 3, strides=None, iou_type='giou', positive_weights=0.1, negative_weights=1.0): self.alpha = alpha self.gamma = gamma self.lambda_p = lambda_p # 平衡正负样本的损失权重 self.temperature = temperature # 突出具有高置信度的位置 # 正负样本损失的权值,论文中并未明确给出,待定 self.positive_weights = positive_weights self.negative_weights = negative_weights if strides is None: strides = [8, 16, 32, 64, 128] self.strides = strides self.box_coder = BoxCoder() self.iou_loss_func = IOULoss(iou_type=iou_type, coord_type='ltrb')