clDNN
detection_output.hpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
18 #pragma once
19 #include <limits>
20 #include "../C/detection_output.h"
21 #include "primitive.hpp"
22 
23 namespace cldnn
24 {
31 
33 enum class prior_box_code_type : int32_t
34 {
35  corner = cldnn_code_type_corner,
36  center_size = cldnn_code_type_center_size,
37  corner_size = cldnn_code_type_corner_size
38 };
39 
43 struct detection_output : public primitive_base<detection_output, CLDNN_PRIMITIVE_DESC(detection_output)>
44 {
45  CLDNN_DECLATE_PRIMITIVE(detection_output)
46 
47 
63  const primitive_id& id,
64  const primitive_id& input_location,
65  const primitive_id& input_confidence,
66  const primitive_id& input_prior_box,
67  const uint32_t num_classes,
68  const uint32_t keep_top_k,
69  const bool share_location = true,
70  const int background_label_id = 0,
71  const float nms_threshold = 0.3,
72  const int top_k = -1,
73  const float eta = 1.f,
74  const prior_box_code_type code_type = prior_box_code_type::corner,
75  const bool variance_encoded_in_target = false,
76  const float confidence_threshold = -std::numeric_limits<float>::max(),
77  const padding& output_padding = padding()
78  )
79  : primitive_base(id, { input_location, input_confidence, input_prior_box }, output_padding)
85  , top_k(top_k)
86  , eta(eta)
90  {}
91 
100  , top_k(dto->top_k)
101  , eta(dto->eta)
102  , code_type(static_cast<prior_box_code_type>(dto->code_type))
105  {}
106 
108  const uint32_t num_classes;
110  const int keep_top_k;
112  const bool share_location;
116  const float nms_threshold;
118  const int top_k;
120  const float eta;
126  const float confidence_threshold;
127 
128 protected:
129  void update_dto(dto& dto) const override
130  {
135  dto.top_k = top_k;
136  dto.eta = eta;
137  dto.code_type = static_cast<int32_t>(code_type);
141  }
142 };
146 }
float eta
Used for adaptive NMS.
const int background_label_id
Background label id (-1 if there is no background class).
Represents data padding information.
Definition: layout.hpp:125
detection_output(const primitive_id &id, const primitive_id &input_location, const primitive_id &input_confidence, const primitive_id &input_prior_box, const uint32_t num_classes, const uint32_t keep_top_k, const bool share_location=true, const int background_label_id=0, const float nms_threshold=0.3, const int top_k=-1, const float eta=1.f, const prior_box_code_type code_type=prior_box_code_type::corner, const bool variance_encoded_in_target=false, const float confidence_threshold=-std::numeric_limits< float >::max(), const padding &output_padding=padding())
Constructs pooling primitive.
int background_label_id
Background label id (-1 if there is no background class).
Generates a list of detections based on location and confidence predictions by doing non maximum supp...
uint32_t keep_top_k
Number of total bounding boxes to be kept per image after NMS step.
const bool share_location
If true, bounding box are shared among different classes.
uint32_t num_classes
Number of classes to be predicted.
const bool variance_encoded_in_target
If true, variance is encoded in target; otherwise we need to adjust the predicted offset accordingly...
int top_k
Maximum number of results to be kept in NMS.
detection_output(const dto *dto)
Constructs a copy from C API cldnn_detection_output_desc.
const float confidence_threshold
Only keep detections with confidences larger than this threshold.
const prior_box_code_type code_type
Type of coding method for bounding box.
const float nms_threshold
Threshold for NMS step.
uint32_t variance_encoded_in_target
If not 0, variance is encoded in target; otherwise we need to adjust the predicted offset accordingly...
const int top_k
Maximum number of results to be kept in NMS.
int32_t code_type
Type of coding method for bounding box. See cldnn_prior_box_code_type.
const float eta
Used for adaptive NMS.
prior_box_code_type
Select method for coding the prior-boxes in the detection output layer.
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
const uint32_t num_classes
Number of classes to be predicted.
base class for all primitives implementations.
Definition: primitive.hpp:190
padding output_padding
Requested output padding.
Definition: primitive.hpp:149
float confidence_threshold
Only keep detections with confidences larger than this threshold.
uint32_t share_location
If not 0, bounding box are shared among different classes.
float nms_threshold
Threshold for NMS step.
const int keep_top_k
Number of total bounding boxes to be kept per image after NMS step.
Generates a list of detections based on location and confidence predictions by doing non maximum supp...