From a338389b2445b0aa422f337393ae0af41bb85132 Mon Sep 17 00:00:00 2001 From: Wenyu Date: Wed, 21 Sep 2022 17:33:05 +0800 Subject: [PATCH] fix simota candidate_topk (#6979) --- 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