proposal.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/op/op.hpp"
8 
9 namespace ngraph
10 {
11  namespace op
12  {
13  // base_size Anchor sizes
14  // pre_nms_topn Number of boxes before nms
15  // post_nms_topn Number of boxes after nms
16  // nms_thresh Threshold for nms
17  // feat_stride Feature stride
18  // min_size Minimum box size
19  // ratio Ratios for anchor generation
20  // scale Scales for anchor generation
21  // clip_before_nms Clip before NMs
22  // clip_after_nms Clip after NMs
23  // normalize Normalize boxes to [0,1]
24  // box_size_scale Scale factor for scaling box size
25  // box_coordinate_scale Scale factor for scaling box coordiate
26  // framework Calculation frameworkrithm to use
28  {
29  size_t base_size;
30  size_t pre_nms_topn;
31  size_t post_nms_topn;
32  float nms_thresh = 0.0f;
33  size_t feat_stride = 1;
34  size_t min_size = 1;
35  std::vector<float> ratio;
36  std::vector<float> scale;
37  bool clip_before_nms = true;
38  bool clip_after_nms = false;
39  bool normalize = false;
40  float box_size_scale = 1.0f;
41  float box_coordinate_scale = 1.0f;
42  std::string framework;
43  bool infer_probs = false;
44  };
45 
46  namespace v0
47  {
48  class NGRAPH_API Proposal : public Op
49  {
50  public:
51  NGRAPH_RTTI_DECLARATION;
52  Proposal() = default;
53  /// \brief Constructs a Proposal operation
54  ///
55  /// \param class_probs Class probability scores
56  /// \param bbox_deltas Prediction of bounding box deltas
57  /// \param image_shape Shape of image
58  /// \param attrs Proposal op attributes
59  Proposal(const Output<Node>& class_probs,
60  const Output<Node>& bbox_deltas,
61  const Output<Node>& image_shape,
62  const ProposalAttrs& attrs);
63 
64  void validate_and_infer_types() override;
65  virtual std::shared_ptr<Node>
66  clone_with_new_inputs(const OutputVector& new_args) const override;
67  const ProposalAttrs& get_attrs() const { return m_attrs; }
68  virtual bool visit_attributes(AttributeVisitor& visitor) override;
69 
70  protected:
71  ProposalAttrs m_attrs;
72  };
73  } // namespace v0
74 
75  namespace v4
76  {
77  class NGRAPH_API Proposal : public op::v0::Proposal
78  {
79  public:
80  NGRAPH_RTTI_DECLARATION;
81  Proposal() = default;
82  /// \brief Constructs a Proposal operation
83  ///
84  /// \param class_probs Class probability scores
85  /// \param bbox_deltas Prediction of bounding box deltas
86  /// \param image_shape Shape of image
87  /// \param attrs Proposal op attributes
88  Proposal(const Output<Node>& class_probs,
89  const Output<Node>& bbox_deltas,
90  const Output<Node>& image_shape,
91  const ProposalAttrs& attrs);
92 
93  void validate_and_infer_types() override;
94  virtual std::shared_ptr<Node>
95  clone_with_new_inputs(const OutputVector& new_args) const override;
96  const ProposalAttrs& get_attrs() const { return m_attrs; }
97  };
98  } // namespace v4
99 
100  using v0::Proposal;
101  } // namespace op
102 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:59
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Root of all actual ops.
Definition: op.hpp:17
Definition: proposal.hpp:49
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:78
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:16
Definition: proposal.hpp:28