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 --- arm_compute/core/Types.h | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) (limited to 'arm_compute/core') diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h index 2c17f273a5..6df74e7b88 100644 --- a/arm_compute/core/Types.h +++ b/arm_compute/core/Types.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -943,6 +944,11 @@ private: std::array _steps; }; +// Bounding Box [xmin, ymin, xmax, ymax] +using BBox = std::array; +// LabelBBox used for map label and bounding box +using LabelBBox = std::map>; + /** Available Detection Output code types */ enum class DetectionOutputLayerCodeType { @@ -1071,6 +1077,116 @@ private: int _num_loc_classes; }; +/** Detection Output layer info */ +class DetectionPostProcessLayerInfo final +{ +public: + /** Default Constructor */ + DetectionPostProcessLayerInfo() + : _max_detections(), + _max_classes_per_detection(), + _nms_score_threshold(), + _iou_threshold(), + _num_classes(), + _scales_values(), + _use_regular_nms(), + _detection_per_class() + { + } + /** Constructor + * + * @param[in] max_detections Number of total detection. + * @param[in] max_classes_per_detection Number of total classes to be kept after NMS step. Used in the Fast Non-Max-Suppression + * @param[in] nms_score_threshold Threshold to be used in NMS + * @param[in] iou_threshold Threshold to be used during the intersection over union. + * @param[in] num_classes Number of classes. + * @param[in] scales_values Scales values used for decode center size boxes. + * @param[in] use_regular_nms (Optional) Boolean to determinate if use regular or fast nms. + * @param[in] detection_per_class (Optional) Number of detection per class. Used in the Regular Non-Max-Suppression + */ + DetectionPostProcessLayerInfo(unsigned int max_detections, unsigned int max_classes_per_detection, float nms_score_threshold, float iou_threshold, unsigned int num_classes, + std::array scales_values, bool use_regular_nms = false, unsigned int detection_per_class = 100) + : _max_detections(max_detections), + _max_classes_per_detection(max_classes_per_detection), + _nms_score_threshold(nms_score_threshold), + _iou_threshold(iou_threshold), + _num_classes(num_classes), + _scales_values(scales_values), + _use_regular_nms(use_regular_nms), + _detection_per_class(detection_per_class) + { + } + /** Get max detections. */ + unsigned int max_detections() const + { + return _max_detections; + } + /** Get max_classes per detection. Used in the Fast Non-Max-Suppression.*/ + unsigned int max_classes_per_detection() const + { + return _max_classes_per_detection; + } + /** Get detection per class. Used in the Regular Non-Max-Suppression */ + unsigned int detection_per_class() const + { + return _detection_per_class; + } + /** Get nms threshold. */ + float nms_score_threshold() const + { + return _nms_score_threshold; + } + /** Get intersection over union threshold. */ + float iou_threshold() const + { + return _iou_threshold; + } + /** Get num classes. */ + unsigned int num_classes() const + { + return _num_classes; + } + /** Get if use regular nms. */ + bool use_regular_nms() const + { + return _use_regular_nms; + } + /** Get y scale value. */ + float scale_value_y() const + { + // Saved as [y,x,h,w] + return _scales_values[0]; + } + /** Get x scale value. */ + float scale_value_x() const + { + // Saved as [y,x,h,w] + return _scales_values[1]; + } + /** Get h scale value. */ + float scale_value_h() const + { + // Saved as [y,x,h,w] + return _scales_values[2]; + } + /** Get w scale value. */ + float scale_value_w() const + { + // Saved as [y,x,h,w] + return _scales_values[3]; + } + +private: + unsigned int _max_detections; + unsigned int _max_classes_per_detection; + float _nms_score_threshold; + float _iou_threshold; + unsigned int _num_classes; + std::array _scales_values; + bool _use_regular_nms; + unsigned int _detection_per_class; +}; + /** Pooling Layer Information class */ class PoolingLayerInfo { -- cgit v1.2.1