From b514ec8e9036adbba46e91bb0a3b74f0a66dce7d Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 2 Apr 2019 16:50:54 +0800 Subject: [PATCH 1/2] Bug fixed: filter the box after swapping which is under the threshold The previous code will swap the current box with the last box if the confidence score of previous box falls below threshold. However, it does not check the confidence score of the swapped box(original last box). --- lib/nms/cpu_nms.pyx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/nms/cpu_nms.pyx b/lib/nms/cpu_nms.pyx index b78ca5b..a0798c9 100644 --- a/lib/nms/cpu_nms.pyx +++ b/lib/nms/cpu_nms.pyx @@ -95,14 +95,14 @@ def cpu_soft_nms(np.ndarray[float, ndim=2] boxes, float sigma=0.5, float Nt=0.3, # if box score falls below threshold, discard the box by swapping with last box # update N - if boxes[pos, 4] < threshold: - boxes[pos,0] = boxes[N-1, 0] - boxes[pos,1] = boxes[N-1, 1] - boxes[pos,2] = boxes[N-1, 2] - boxes[pos,3] = boxes[N-1, 3] - boxes[pos,4] = boxes[N-1, 4] - N = N - 1 - pos = pos - 1 + if boxes[pos, 4] < threshold: + boxes[pos,0] = boxes[N-1, 0] + boxes[pos,1] = boxes[N-1, 1] + boxes[pos,2] = boxes[N-1, 2] + boxes[pos,3] = boxes[N-1, 3] + boxes[pos,4] = boxes[N-1, 4] + N = N - 1 + pos = pos - 1 pos = pos + 1 From 1267c154469b03cd62cdf01ca746027233df7795 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 4 Apr 2019 10:47:53 +0800 Subject: [PATCH 2/2] Update cpu_nms.pyx --- lib/nms/cpu_nms.pyx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/nms/cpu_nms.pyx b/lib/nms/cpu_nms.pyx index a0798c9..bedd0d4 100644 --- a/lib/nms/cpu_nms.pyx +++ b/lib/nms/cpu_nms.pyx @@ -95,14 +95,14 @@ def cpu_soft_nms(np.ndarray[float, ndim=2] boxes, float sigma=0.5, float Nt=0.3, # if box score falls below threshold, discard the box by swapping with last box # update N - if boxes[pos, 4] < threshold: - boxes[pos,0] = boxes[N-1, 0] - boxes[pos,1] = boxes[N-1, 1] - boxes[pos,2] = boxes[N-1, 2] - boxes[pos,3] = boxes[N-1, 3] - boxes[pos,4] = boxes[N-1, 4] - N = N - 1 - pos = pos - 1 + if boxes[pos, 4] < threshold: + boxes[pos,0] = boxes[N-1, 0] + boxes[pos,1] = boxes[N-1, 1] + boxes[pos,2] = boxes[N-1, 2] + boxes[pos,3] = boxes[N-1, 3] + boxes[pos,4] = boxes[N-1, 4] + N = N - 1 + pos = pos - 1 pos = pos + 1