proposal.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 "ngraph/op/op.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  // base_size Anchor sizes
26  // pre_nms_topn Number of boxes before nms
27  // post_nms_topn Number of boxes after nms
28  // nms_thresh Threshold for nms
29  // feat_stride Feature stride
30  // min_size Minimum box size
31  // ratio Ratios for anchor generation
32  // scale Scales for anchor generation
33  // clip_before_nms Clip before NMs
34  // clip_after_nms Clip after NMs
35  // normalize Normalize boxes to [0,1]
36  // box_size_scale Scale factor for scaling box size
37  // box_coordinate_scale Scale factor for scaling box coordiate
38  // framework Calculation frameworkrithm to use
40  {
41  size_t base_size;
42  size_t pre_nms_topn;
43  size_t post_nms_topn;
44  float nms_thresh = 0.0f;
45  size_t feat_stride = 1;
46  size_t min_size = 1;
47  std::vector<float> ratio;
48  std::vector<float> scale;
49  bool clip_before_nms = true;
50  bool clip_after_nms = false;
51  bool normalize = false;
52  float box_size_scale = 1.0f;
53  float box_coordinate_scale = 1.0f;
54  std::string framework;
55  bool infer_probs = false;
56  };
57 
58  namespace v0
59  {
60  class NGRAPH_API Proposal : public Op
61  {
62  public:
63  NGRAPH_RTTI_DECLARATION;
64  Proposal() = default;
65  /// \brief Constructs a Proposal operation
66  ///
67  /// \param class_probs Class probability scores
68  /// \param bbox_deltas Prediction of bounding box deltas
69  /// \param image_shape Shape of image
70  /// \param attrs Proposal op attributes
71  Proposal(const Output<Node>& class_probs,
72  const Output<Node>& bbox_deltas,
73  const Output<Node>& image_shape,
74  const ProposalAttrs& attrs);
75 
76  void validate_and_infer_types() override;
77  virtual std::shared_ptr<Node>
78  clone_with_new_inputs(const OutputVector& new_args) const override;
79  const ProposalAttrs& get_attrs() const { return m_attrs; }
80  virtual bool visit_attributes(AttributeVisitor& visitor) override;
81 
82  protected:
83  ProposalAttrs m_attrs;
84  };
85  }
86 
87  namespace v4
88  {
89  class NGRAPH_API Proposal : public op::v0::Proposal
90  {
91  public:
92  NGRAPH_RTTI_DECLARATION;
93  Proposal() = default;
94  /// \brief Constructs a Proposal operation
95  ///
96  /// \param class_probs Class probability scores
97  /// \param bbox_deltas Prediction of bounding box deltas
98  /// \param image_shape Shape of image
99  /// \param attrs Proposal op attributes
100  Proposal(const Output<Node>& class_probs,
101  const Output<Node>& bbox_deltas,
102  const Output<Node>& image_shape,
103  const ProposalAttrs& attrs);
104 
105  void validate_and_infer_types() override;
106  virtual std::shared_ptr<Node>
107  clone_with_new_inputs(const OutputVector& new_args) const override;
108  const ProposalAttrs& get_attrs() const { return m_attrs; }
109  };
110  }
111 
112  using v0::Proposal;
113  }
114 }
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
Definition: proposal.hpp:61
Proposal(const Output< Node > &class_probs, const Output< Node > &bbox_deltas, const Output< Node > &image_shape, const ProposalAttrs &attrs)
Constructs a Proposal operation.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
Definition: proposal.hpp:90
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
Proposal(const Output< Node > &class_probs, const Output< Node > &bbox_deltas, const Output< Node > &image_shape, const ProposalAttrs &attrs)
Constructs a Proposal operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: proposal.hpp:40