From 883bad7ef34c3429b3338d5544a8cdf3b60cd1e8 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Mon, 15 Jul 2019 17:33:07 +0100 Subject: COMPMID-1849: Add DetectorPostProcess operator Part1 - Rework of CPPNonMaximumSuppression Change-Id: I2b34fbd12188db49b0ac050a12312494eeefd819 Signed-off-by: Isabella Gottardi Reviewed-on: https://review.mlplatform.org/c/1585 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- tests/validation/reference/NonMaxSuppression.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/validation/reference') diff --git a/tests/validation/reference/NonMaxSuppression.cpp b/tests/validation/reference/NonMaxSuppression.cpp index 5b7980d2f0..8fc370b7af 100644 --- a/tests/validation/reference/NonMaxSuppression.cpp +++ b/tests/validation/reference/NonMaxSuppression.cpp @@ -76,10 +76,10 @@ inline float compute_size(const std::pair &min, const std::pair &b0_min, const std::pair &b0_max, const std::pair &b1_min, const std::pair &b1_max, float b0_size, float b1_size) { - const float inter = std::max(std::min(b0_max.first, b1_max.first) - std::max(b0_min.first, b1_min.first), 0.0) * std::max(std::min(b0_max.second, + const float inter = std::max(std::min(b0_max.first, b1_max.first) - std::max(b0_min.first, b1_min.first), 0.0f) * std::max(std::min(b0_max.second, b1_max.second) - std::max(b0_min.second, b1_min.second), - 0.0); + 0.0f); return inter / (b0_size + b1_size - inter); } @@ -107,7 +107,7 @@ inline std::vector get_candidates(const SimpleTensor &score std::vector candidates_vector; for(int i = 0; i < scores.num_elements(); ++i) { - if(scores[i] > threshold) + if(scores[i] >= threshold) { const auto cb = CandidateBox({ i, scores[i] }); candidates_vector.push_back(cb); @@ -115,7 +115,7 @@ inline std::vector get_candidates(const SimpleTensor &score } std::stable_sort(candidates_vector.begin(), candidates_vector.end(), [](const CandidateBox bb0, const CandidateBox bb1) { - return bb0.second >= bb1.second; + return bb0.second > bb1.second; }); return candidates_vector; } @@ -155,6 +155,12 @@ SimpleTensor non_max_suppression(const SimpleTensor &bboxes, const S } } std::copy_n(selected.begin(), selected.size(), indices.data()); + + for(unsigned int i = selected.size(); i < max_output_size; ++i) + { + indices[i] = -1; + } + return indices; } } // namespace reference -- cgit v1.2.1