From db6e8a99b024a697cce1ca5198724c3805440b2a Mon Sep 17 00:00:00 2001 From: antkillerfarm Date: Thu, 15 Oct 2020 11:02:07 +0800 Subject: GitHub#465 Fix NonMaxSuppression If visited flag set true, it should not be visited any more. For example, if we put 10 boxes (ordered by score) into NonMaxSuppression: * Step1: Suppose Box 2/3/6/8 are suppressed by Box 1. Box 4/5/7/9/10 survived. * Step2: Correct way: We use Box 4 to suppress the survive boxes. Prior to this commit: Box 4 may be suppressed by Box 2, even Box 2 is already suppressed by Box 1... Signed-off-by: Antkillerfarm Change-Id: I38d7a84287649827a16565748592fb562b4df5d5 --- src/backends/reference/workloads/DetectionPostProcess.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/backends/reference/workloads') diff --git a/src/backends/reference/workloads/DetectionPostProcess.cpp b/src/backends/reference/workloads/DetectionPostProcess.cpp index f80f20a441..2108efe8f3 100644 --- a/src/backends/reference/workloads/DetectionPostProcess.cpp +++ b/src/backends/reference/workloads/DetectionPostProcess.cpp @@ -85,14 +85,14 @@ std::vector NonMaxSuppression(unsigned int numBoxes, if (!visited[sortedIndices[i]]) { outputIndices.push_back(indicesAboveThreshold[sortedIndices[i]]); - } - for (unsigned int j = i + 1; j < numAboveThreshold; ++j) - { - unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4; - unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4; - if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold) + for (unsigned int j = i + 1; j < numAboveThreshold; ++j) { - visited[sortedIndices[j]] = true; + unsigned int iIndex = indicesAboveThreshold[sortedIndices[i]] * 4; + unsigned int jIndex = indicesAboveThreshold[sortedIndices[j]] * 4; + if (IntersectionOverUnion(&boxCorners[iIndex], &boxCorners[jIndex]) > nmsIouThreshold) + { + visited[sortedIndices[j]] = true; + } } } } -- cgit v1.2.1