未验证 提交 d40a6ddb 编写于 作者: L LokeZhou 提交者: GitHub

assigner delete mask_positive (#8279)

上级 d08e41f1
......@@ -222,4 +222,4 @@ class ATSSAssigner(nn.Layer):
paddle.zeros_like(gather_scores))
assigned_scores *= gather_scores.unsqueeze(-1)
return assigned_labels, assigned_bboxes, assigned_scores, mask_positive
return assigned_labels, assigned_bboxes, assigned_scores
......@@ -191,4 +191,4 @@ class TaskAlignedAssigner(nn.Layer):
alignment_metrics = alignment_metrics.max(-2).unsqueeze(-1)
assigned_scores = assigned_scores * alignment_metrics
return assigned_labels, assigned_bboxes, assigned_scores, mask_positive
return assigned_labels, assigned_bboxes, assigned_scores
......@@ -179,4 +179,4 @@ class TaskAlignedAssigner_CR(nn.Layer):
alignment_metrics = alignment_metrics.max(-2).unsqueeze(-1)
assigned_scores = assigned_scores * alignment_metrics
return assigned_labels, assigned_bboxes, assigned_scores, mask_positive
return assigned_labels, assigned_bboxes, assigned_scores
......@@ -651,7 +651,7 @@ class PicoHeadV2(GFLHead):
# label assignment
if gt_meta['epoch_id'] < self.static_assigner_epoch:
assigned_labels, assigned_bboxes, assigned_scores, _ = self.static_assigner(
assigned_labels, assigned_bboxes, assigned_scores = self.static_assigner(
anchors,
num_anchors_list,
gt_labels,
......@@ -662,7 +662,7 @@ class PicoHeadV2(GFLHead):
pred_bboxes=pred_bboxes.detach() * stride_tensor_list)
else:
assigned_labels, assigned_bboxes, assigned_scores, _ = self.assigner(
assigned_labels, assigned_bboxes, assigned_scores = self.assigner(
pred_scores.detach(),
pred_bboxes.detach() * stride_tensor_list,
centers,
......
......@@ -121,7 +121,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
pad_gt_mask = gt_meta['pad_gt_mask']
# label assignment
if gt_meta['epoch_id'] < self.static_assigner_epoch:
assigned_labels, assigned_bboxes, assigned_scores, _ = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.static_assigner(
anchors,
num_anchors_list,
......@@ -133,7 +133,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
alpha_l = 0.25
else:
if self.sm_use:
assigned_labels, assigned_bboxes, assigned_scores, _ = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.assigner(
pred_scores.detach(),
pred_bboxes.detach() * stride_tensor,
......@@ -144,7 +144,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
pad_gt_mask,
bg_index=self.num_classes)
else:
assigned_labels, assigned_bboxes, assigned_scores, _ = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.assigner(
pred_scores.detach(),
pred_bboxes.detach() * stride_tensor,
......
......@@ -387,7 +387,7 @@ class PPYOLOEHead(nn.Layer):
pad_gt_mask = gt_meta['pad_gt_mask']
# label assignment
if gt_meta['epoch_id'] < self.static_assigner_epoch:
assigned_labels, assigned_bboxes, assigned_scores, mask_positive = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.static_assigner(
anchors,
num_anchors_list,
......@@ -400,7 +400,7 @@ class PPYOLOEHead(nn.Layer):
else:
if self.sm_use:
# only used in smalldet of PPYOLOE-SOD model
assigned_labels, assigned_bboxes, assigned_scores, mask_positive = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.assigner(
pred_scores.detach(),
pred_bboxes.detach() * stride_tensor,
......@@ -413,7 +413,7 @@ class PPYOLOEHead(nn.Layer):
else:
if aux_pred is None:
if not hasattr(self, "assigned_labels"):
assigned_labels, assigned_bboxes, assigned_scores, mask_positive = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.assigner(
pred_scores.detach(),
pred_bboxes.detach() * stride_tensor,
......@@ -427,15 +427,15 @@ class PPYOLOEHead(nn.Layer):
self.assigned_labels = assigned_labels
self.assigned_bboxes = assigned_bboxes
self.assigned_scores = assigned_scores
self.mask_positive = mask_positive
else:
# only used in distill
assigned_labels = self.assigned_labels
assigned_bboxes = self.assigned_bboxes
assigned_scores = self.assigned_scores
mask_positive = self.mask_positive
else:
assigned_labels, assigned_bboxes, assigned_scores, mask_positive = \
assigned_labels, assigned_bboxes, assigned_scores = \
self.assigner(
pred_scores_aux.detach(),
pred_bboxes_aux.detach() * stride_tensor,
......@@ -451,14 +451,12 @@ class PPYOLOEHead(nn.Layer):
assign_out_dict = self.get_loss_from_assign(
pred_scores, pred_distri, pred_bboxes, anchor_points_s,
assigned_labels, assigned_bboxes, assigned_scores, mask_positive,
alpha_l)
assigned_labels, assigned_bboxes, assigned_scores, alpha_l)
if aux_pred is not None:
assign_out_dict_aux = self.get_loss_from_assign(
aux_pred[0], aux_pred[1], pred_bboxes_aux, anchor_points_s,
assigned_labels, assigned_bboxes, assigned_scores,
mask_positive, alpha_l)
assigned_labels, assigned_bboxes, assigned_scores, alpha_l)
loss = {}
for key in assign_out_dict.keys():
loss[key] = assign_out_dict[key] + assign_out_dict_aux[key]
......@@ -469,7 +467,7 @@ class PPYOLOEHead(nn.Layer):
def get_loss_from_assign(self, pred_scores, pred_distri, pred_bboxes,
anchor_points_s, assigned_labels, assigned_bboxes,
assigned_scores, mask_positive, alpha_l):
assigned_scores, alpha_l):
# cls loss
if self.use_varifocal_loss:
one_hot_label = F.one_hot(assigned_labels,
......@@ -490,7 +488,6 @@ class PPYOLOEHead(nn.Layer):
self.distill_pairs['pred_cls_scores'] = pred_scores
self.distill_pairs['pos_num'] = assigned_scores_sum
self.distill_pairs['assigned_scores'] = assigned_scores
self.distill_pairs['mask_positive'] = mask_positive
one_hot_label = F.one_hot(assigned_labels,
self.num_classes + 1)[..., :-1]
self.distill_pairs['target_labels'] = one_hot_label
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册