detection_output.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 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 
17 #pragma once
18 
19 #include "ngraph/op/op.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
26  {
27  int num_classes;
28  int background_label_id = 0;
29  int top_k = -1;
30  bool variance_encoded_in_target = false;
31  std::vector<int> keep_top_k = {1};
32  std::string code_type = std::string{"caffe.PriorBoxParameter.CORNER"};
33  bool share_location = true;
34  float nms_threshold;
35  float confidence_threshold = std::numeric_limits<float>::min();
36  bool clip_after_nms = false;
37  bool clip_before_nms = false;
38  bool decrease_label_id = false;
39  bool normalized = false;
40  size_t input_height = 1;
41  size_t input_width = 1;
42  float objectness_score = 0;
43  };
44 
45  namespace v0
46  {
47  /// \brief Layer which performs non-max suppression to
48  /// generate detection output using location and confidence predictions
49  class NGRAPH_API DetectionOutput : public Op
50  {
51  public:
52  static constexpr NodeTypeInfo type_info{"DetectionOutput", 0};
53  const NodeTypeInfo& get_type_info() const override { return type_info; }
54  DetectionOutput() = default;
55  /// \brief Constructs a DetectionOutput operation
56  ///
57  /// \param box_logits Box logits
58  /// \param class_preds Class predictions
59  /// \param proposals Proposals
60  /// \param aux_class_preds Auxilary class predictions
61  /// \param aux_box_preds Auxilary box predictions
62  /// \param attrs Detection Output attributes
63  DetectionOutput(const Output<Node>& box_logits,
64  const Output<Node>& class_preds,
65  const Output<Node>& proposals,
66  const Output<Node>& aux_class_preds,
67  const Output<Node>& aux_box_preds,
68  const DetectionOutputAttrs& attrs);
69 
70  /// \brief Constructs a DetectionOutput operation
71  ///
72  /// \param box_logits Box logits
73  /// \param class_preds Class predictions
74  /// \param proposals Proposals
75  /// \param attrs Detection Output attributes
76  DetectionOutput(const Output<Node>& box_logits,
77  const Output<Node>& class_preds,
78  const Output<Node>& proposals,
79  const DetectionOutputAttrs& attrs);
80 
81  void validate_and_infer_types() override;
82 
83  virtual std::shared_ptr<Node>
84  clone_with_new_inputs(const OutputVector& new_args) const override;
85 
86  const DetectionOutputAttrs& get_attrs() const { return m_attrs; }
87  virtual bool visit_attributes(AttributeVisitor& visitor) override;
88 
89  private:
90  DetectionOutputAttrs m_attrs;
91  };
92  }
93  using v0::DetectionOutput;
94  }
95 }
ngraph::op::v0::DetectionOutput
Layer which performs non-max suppression to generate detection output using location and confidence p...
Definition: detection_output.hpp:50
ngraph::op::v0::DetectionOutput::DetectionOutput
DetectionOutput(const Output< Node > &box_logits, const Output< Node > &class_preds, const Output< Node > &proposals, const DetectionOutputAttrs &attrs)
Constructs a DetectionOutput operation.
ngraph::op::v0::DetectionOutput::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: detection_output.hpp:53
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v0::DetectionOutput::validate_and_infer_types
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ngraph::op::DetectionOutputAttrs
Definition: detection_output.hpp:26
ngraph::op::v0::DetectionOutput::DetectionOutput
DetectionOutput(const Output< Node > &box_logits, const Output< Node > &class_preds, const Output< Node > &proposals, const Output< Node > &aux_class_preds, const Output< Node > &aux_box_preds, const DetectionOutputAttrs &attrs)
Constructs a DetectionOutput operation.
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29