From a7acb3cbabeb66ce647684466a04c96b2963c9c9 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Tue, 8 Jan 2019 13:48:44 +0000 Subject: COMPMID-1849: Implement CPPDetectionPostProcessLayer * Add DetectionPostProcessLayer * Add DetectionPostProcessLayer at the graph Change-Id: I7e56f6cffc26f112d26dfe74853085bb8ec7d849 Signed-off-by: Isabella Gottardi Reviewed-on: https://review.mlplatform.org/c/1639 Reviewed-by: Giuseppe Rossini Tested-by: Arm Jenkins --- .../CPP/functions/CPPDetectionOutputLayer.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp') diff --git a/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp b/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp index a1f4e6e89c..13a34b43cd 100644 --- a/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp +++ b/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp @@ -166,9 +166,9 @@ void retrieve_all_conf_scores(const ITensor *input_conf, const int num, * @param[out] all_location_predictions All the location predictions. * */ -void retrieve_all_priorbox(const ITensor *input_priorbox, - const int num_priors, - std::vector &all_prior_bboxes, +void retrieve_all_priorbox(const ITensor *input_priorbox, + const int num_priors, + std::vector &all_prior_bboxes, std::vector> &all_prior_variances) { for(int i = 0; i < num_priors; ++i) @@ -206,9 +206,9 @@ void retrieve_all_priorbox(const ITensor *input_priorbox, * @param[out] decode_bbox The decoded bboxes. * */ -void DecodeBBox(const NormalizedBBox &prior_bbox, const std::array &prior_variance, +void DecodeBBox(const BBox &prior_bbox, const std::array &prior_variance, const DetectionOutputLayerCodeType code_type, const bool variance_encoded_in_target, - const bool clip_bbox, const NormalizedBBox &bbox, NormalizedBBox &decode_bbox) + const bool clip_bbox, const BBox &bbox, BBox &decode_bbox) { // if the variance is encoded in target, we simply need to add the offset predictions // otherwise we need to scale the offset accordingly. @@ -287,7 +287,7 @@ void DecodeBBox(const NormalizedBBox &prior_bbox, const std::array &pr * @param[out] indices The kept indices of bboxes after nms. * */ -void ApplyNMSFast(const std::vector &bboxes, +void ApplyNMSFast(const std::vector &bboxes, const std::vector &scores, const float score_threshold, const float nms_threshold, const float eta, const int top_k, std::vector &indices) @@ -329,7 +329,7 @@ void ApplyNMSFast(const std::vector &bboxes, if(keep) { // Compute the jaccard (intersection over union IoU) overlap between two bboxes. - NormalizedBBox intersect_bbox = std::array({ { 0, 0, 0, 0 } }); + BBox intersect_bbox = std::array({ 0, 0, 0, 0 }); if(bboxes[kept_idx][0] > bboxes[idx][2] || bboxes[kept_idx][2] < bboxes[idx][0] || bboxes[kept_idx][1] > bboxes[idx][3] || bboxes[kept_idx][3] < bboxes[idx][1]) { intersect_bbox = std::array({ { 0, 0, 0, 0 } }); @@ -466,7 +466,7 @@ void CPPDetectionOutputLayer::run() } ARM_COMPUTE_ERROR_ON_MSG(_all_location_predictions[i].find(label) == _all_location_predictions[i].end(), "Could not find location predictions for label %d.", label); - const std::vector &label_loc_preds = _all_location_predictions[i].find(label)->second; + const std::vector &label_loc_preds = _all_location_predictions[i].find(label)->second; const int num_bboxes = _all_prior_bboxes.size(); ARM_COMPUTE_ERROR_ON(_all_prior_variances[i].size() != 4); @@ -499,8 +499,8 @@ void CPPDetectionOutputLayer::run() { ARM_COMPUTE_ERROR("Could not find predictions for label %d.", label); } - const std::vector &scores = conf_scores.find(c)->second; - const std::vector &bboxes = decode_bboxes.find(label)->second; + const std::vector &scores = conf_scores.find(c)->second; + const std::vector &bboxes = decode_bboxes.find(label)->second; ApplyNMSFast(bboxes, scores, _info.confidence_threshold(), _info.nms_threshold(), _info.eta(), _info.top_k(), indices[c]); @@ -572,8 +572,8 @@ void CPPDetectionOutputLayer::run() // or there are no location predictions for current label. ARM_COMPUTE_ERROR("Could not find predictions for the label %d.", label); } - const std::vector &bboxes = decode_bboxes.find(loc_label)->second; - const std::vector &indices = it.second; + const std::vector &bboxes = decode_bboxes.find(loc_label)->second; + const std::vector &indices = it.second; for(auto idx : indices) { -- cgit v1.2.1