From 7e19ac76273e30b64f5e34ce3a2f98e54abe4c8d Mon Sep 17 00:00:00 2001 From: Wenyu Date: Fri, 23 Sep 2022 11:19:39 +0800 Subject: [PATCH] fix simota candidate_topk (#6979) (#7001) --- ppdet/modeling/assigners/simota_assigner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ppdet/modeling/assigners/simota_assigner.py b/ppdet/modeling/assigners/simota_assigner.py index 4b34027e3..92fe84d7f 100644 --- a/ppdet/modeling/assigners/simota_assigner.py +++ b/ppdet/modeling/assigners/simota_assigner.py @@ -115,7 +115,10 @@ class SimOTAAssigner(object): def dynamic_k_matching(self, cost_matrix, pairwise_ious, num_gt): match_matrix = np.zeros_like(cost_matrix.numpy()) # select candidate topk ious for dynamic-k calculation - topk_ious, _ = paddle.topk(pairwise_ious, self.candidate_topk, axis=0) + topk_ious, _ = paddle.topk( + pairwise_ious, + min(self.candidate_topk, pairwise_ious.shape[0]), + axis=0) # calculate dynamic k for each gt dynamic_ks = paddle.clip(topk_ious.sum(0).cast('int'), min=1) for gt_idx in range(num_gt): -- GitLab