experimental_detectron_detection_output.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 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 <cstddef>
20 #include <vector>
21 #include "ngraph/attribute_adapter.hpp"
22 #include "ngraph/op/op.hpp"
23 #include "ngraph/op/util/attr_types.hpp"
24 
25 namespace ngraph
26 {
27  namespace op
28  {
29  namespace v6
30  {
31  /// \brief An operation ExperimentalDetectronDetectionOutput, according to
32  /// the repository https://github.com/openvinotoolkit/training_extensions
33  /// (see pytorch_toolkit/instance_segmentation/segmentoly/rcnn/detection_output.py).
34  class NGRAPH_API ExperimentalDetectronDetectionOutput : public Op
35  {
36  public:
37  NGRAPH_RTTI_DECLARATION;
38 
39  /// \brief Structure that specifies attributes of the operation
40  struct Attributes
41  {
42  // specifies score threshold
43  float score_threshold;
44  // specifies NMS threshold
45  float nms_threshold;
46  // specifies maximal delta of logarithms for width and height
47  float max_delta_log_wh;
48  // specifies number of detected classes
49  int64_t num_classes;
50  // specifies maximal number of detections per class
51  int64_t post_nms_count;
52  // specifies maximual number of detections per image
53  size_t max_detections_per_image;
54  // a flag specifies whether to delete background classes or not
55  // `true` means background classes should be deleted,
56  // `false` means background classes shouldn't be deleted.
57  bool class_agnostic_box_regression;
58  // specifies deltas of weights
59  std::vector<float> deltas_weights;
60  };
61 
63  /// \brief Constructs a ExperimentalDetectronDetectionOutput operation.
64  ///
65  /// \param input_rois Input rois
66  /// \param input_deltas Input deltas
67  /// \param input_scores Input scores
68  /// \param input_im_info Input image info
69  /// \param attrs Attributes attributes
71  const Output<Node>& input_deltas,
72  const Output<Node>& input_scores,
73  const Output<Node>& input_im_info,
74  const Attributes& attrs);
75  bool visit_attributes(AttributeVisitor& visitor) override;
76 
77  void validate_and_infer_types() override;
78 
79  std::shared_ptr<Node>
80  clone_with_new_inputs(const OutputVector& new_args) const override;
81  /// \brief Returns attributes of the operation ExperimentalDetectronDetectionOutput
82  const Attributes& get_attrs() const { return m_attrs; }
83  private:
84  Attributes m_attrs;
85  };
86  }
87  }
88 }
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:71
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Root of all actual ops.
Definition: op.hpp:29
An operation ExperimentalDetectronDetectionOutput, according to the repository https://github....
Definition: experimental_detectron_detection_output.hpp:35
const Attributes & get_attrs() const
Returns attributes of the operation ExperimentalDetectronDetectionOutput.
Definition: experimental_detectron_detection_output.hpp:82
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ExperimentalDetectronDetectionOutput(const Output< Node > &input_rois, const Output< Node > &input_deltas, const Output< Node > &input_scores, const Output< Node > &input_im_info, const Attributes &attrs)
Constructs a ExperimentalDetectronDetectionOutput operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Structure that specifies attributes of the operation.
Definition: experimental_detectron_detection_output.hpp:41