diff --git a/ppdet/modeling/assigners/simota_assigner.py b/ppdet/modeling/assigners/simota_assigner.py index abc055d29e3405174753e03501b40817accb583b..4ec87cbcf9527aa08c0ca3fd856b0a9a1af7170d 100644 --- a/ppdet/modeling/assigners/simota_assigner.py +++ b/ppdet/modeling/assigners/simota_assigner.py @@ -241,8 +241,8 @@ class SimOTAAssigner(object): pos_inds, neg_inds, pos_gt_bboxes, pos_assigned_gt_inds \ = self.get_sample(assigned_gt_inds, gt_bboxes.numpy()) - bbox_target = np.zeros_like(flatten_bboxes) - bbox_weight = np.zeros_like(flatten_bboxes) + bbox_target = np.zeros(flatten_bboxes.shape, paddle.common_ops_import.convert_dtype(flatten_bboxes.dtype)) + bbox_weight = np.zeros_like(bbox_target) label = np.ones([num_bboxes], dtype=np.int64) * self.num_classes label_weight = np.zeros([num_bboxes], dtype=np.float32) diff --git a/ppdet/modeling/transformers/matchers.py b/ppdet/modeling/transformers/matchers.py index 72459a3f909806f212a4b204a50a494875589e51..8082c0e625563b9d4b80e21d8fdbe8c61763630a 100644 --- a/ppdet/modeling/transformers/matchers.py +++ b/ppdet/modeling/transformers/matchers.py @@ -175,10 +175,16 @@ class HungarianMatcher(nn.Layer): C = C.reshape([bs, num_queries, -1]) C = [a.squeeze(0) for a in C.chunk(bs)] sizes = [a.shape[0] for a in gt_bbox] - indices = [ - linear_sum_assignment(c.split(sizes, -1)[i].numpy()) - for i, c in enumerate(C) - ] + if hasattr(paddle.Tensor, "contiguous"): + indices = [ + linear_sum_assignment(c.split(sizes, -1)[i].contiguous().numpy()) + for i, c in enumerate(C) + ] + else: + indices = [ + linear_sum_assignment(c.split(sizes, -1)[i].numpy()) + for i, c in enumerate(C) + ] return [(paddle.to_tensor( i, dtype=paddle.int64), paddle.to_tensor( j, dtype=paddle.int64)) for i, j in indices]