Skip to content

Commit

Permalink
Porting-[ONNX FE] Extend ONNX FE-#12510
Browse files Browse the repository at this point in the history
  • Loading branch information
sgolebiewski-intel committed Aug 19, 2022
1 parent 41228e4 commit 9380842
Showing 1 changed file with 124 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,131 +5,162 @@
GenerateProposals
=================

:target:`doxid-openvino_docs_ops_detection__generate_proposals_9_1md_openvino_docs_ops_detection_generateproposals_9` **Versioned name** : *GenerateProposals-9*
:target:`doxid-openvino_docs_ops_detection__generate_proposals_9_1md_openvino_docs_ops_detection_generateproposals_9`

**Versioned name** : *GenerateProposals-9*

**Category** : *Object detection*

**Short description** : The *GenerateProposals* operation proposes ROIs and their scores based on input data for each image in the batch.
**Short description** : The *GenerateProposals* operation proposes ROIs and
their scores based on input data for each image in the batch.

**Detailed description** : The operation performs the following steps for each image:

#. Transposes and reshapes predicted bounding boxes deltas and scores to get them into the same dimension order as the anchors.
#. Transposes and reshapes predicted bounding boxes deltas and scores to get
them into the same dimension order as the anchors.

#. Transforms anchors and deltas into proposal bboxes and clips proposal bboxes to an image. The attribute *normalized* indicates whether the proposal bboxes are normalized or not.
#. Transforms anchors and deltas into proposal bboxes and clips proposal
bboxes to an image. The attribute *normalized* indicates whether the
proposal bboxes are normalized or not.

#. Sorts all ``(proposal, score)`` pairs by score from highest to lowest; order of pairs with equal scores is undefined.
#. Sorts all ``(proposal, score)`` pairs by score from highest to lowest;
order of pairs with equal scores is undefined.

#. Takes top *pre_nms_count* proposals, if total number of proposals is less than *pre_nms_count* takes all proposals.
#. Takes top *pre_nms_count* proposals, if total number of proposals is less
than *pre_nms_count* takes all proposals.

#. Removes predicted boxes with either height or width <*min_size*.

#. Applies non-maximum suppression with *adaptive_nms_threshold*. The initial value of *adaptive_nms_threshold* is *nms_threshold*. If ``nms_eta < 1`` and ``adaptive_threshold > 0.5``, update ``adaptive_threshold \*= nms_eta``.
#. Applies non-maximum suppression with *adaptive_nms_threshold*. The initial
value of *adaptive_nms_threshold* is *nms_threshold*. If ``nms_eta < 1``
and ``adaptive_threshold > 0.5``, update ``adaptive_threshold \*= nms_eta``.

#. Takes and returns top proposals after nms operation. The number of returned proposals in each image is dynamic and is specified by output port 3 ``rpnroisnum``. And the max number of proposals in each image is specified by attribute *post_nms_count*.
#. Takes and returns top proposals after nms operation. The number of returned
proposals in each image is dynamic and is specified by output port 3
``rpnroisnum``. And the max number of proposals in each image is specified
by attribute *post_nms_count*.

All proposals of the whole batch are concated image by image, and distinguishable through outputs.
All proposals of the whole batch are concated image by image, and
distinguishable through outputs.

**Attributes** :

* *min_size*

* **Description** : The *min_size* attribute specifies minimum box width and height.


* **Description** : The *min_size* attribute specifies minimum box width
and height.

* **Range of values** : non-negative floating-point number

* **Type** : float

* **Required** : *yes*

* *nms_threshold*

* **Description** : The *nms_threshold* attribute specifies threshold to be used in the NMS stage.


* **Description** : The *nms_threshold* attribute specifies threshold to be
used in the NMS stage.

* **Range of values** : non-negative floating-point number

* **Type** : float

* **Required** : *yes*

* *pre_nms_count*

* **Description** : The *pre_nms_count* attribute specifies number of top-n proposals before NMS.


* **Description** : The *pre_nms_count* attribute specifies number of top-n
proposals before NMS.

* **Range of values** : non-negative integer number

* **Type** : int

* **Required** : *yes*

* *post_nms_count*

* **Description** : The *post_nms_count* attribute specifies number of top-n proposals after NMS.


* **Description** : The *post_nms_count* attribute specifies number of
top-n proposals after NMS.

* **Range of values** : non-negative integer number

* **Type** : int

* **Required** : *yes*

* *normalized*

* **Description** : *normalized* is a flag that indicates whether proposal bboxes are normalized or not.


* **Description** : *normalized* is a flag that indicates whether proposal
bboxes are normalized or not.

* **Range of values** : true or false

* *true* - the bbox coordinates are normalized.

* *false* - the bbox coordinates are not normalized.

* **Type** : boolean

* **Default value** : True

* **Required** : *no*

* *nms_eta*

* **Description** : eta parameter for adaptive NMS.
* **Range of values** : a floating-point number in close range ``[0, 1.0]``.

* **Range of values** : a floating-point number in closed range ``[0, 1.0]``.

* **Type** : float

* **Default value** : ``1.0``

* **Required** : *no*

* *roi_num_type*

* **Description** : the type of element of output 3 ``rpnroisnum``.

* **Range of values** : i32, i64

* **Type** : string

* **Default value** : ``i64``

* **Required** : *no*

**Inputs**

* **1** : ``im_info`` - tensor of type *T* and shape ``[num_batches, 3]`` or ``[num_batches, 4]`` providing input image info. The image info is layout as ``[image_height, image_width, scale_height_and_width]`` or as ``[image_height, image_width, scale_height, scale_width]``. **Required.**
* **1** : ``im_info`` - tensor of type *T* and shape ``[num_batches, 3]`` or
``[num_batches, 4]`` providing input image info. The image info is layout as
``[image_height, image_width, scale_height_and_width]`` or as
``[image_height, image_width, scale_height, scale_width]``. **Required.**

* **2** : ``anchors`` - tensor of type *T* with shape ``[height, width, number_of_anchors, 4]`` providing anchors. Each anchor is layouted as ``[xmin, ymin, xmax, ymax]``. **Required.**
* **2** : ``anchors`` - tensor of type *T* with shape ``[height, width,
number_of_anchors, 4]`` providing anchors. Each anchor is layouted as
``[xmin, ymin, xmax, ymax]``. **Required.**

* **3** : ``boxesdeltas`` - tensor of type *T* with shape ``[num_batches, number_of_anchors \* 4, height, width]`` providing deltas for anchors. The delta consists of 4 element tuples with layout ``[dx, dy, log(dw), log(dh)]``. **Required.**
* **3** : ``boxesdeltas`` - tensor of type *T* with shape ``[num_batches,
number_of_anchors \* 4, height, width]`` providing deltas for anchors. The
delta consists of 4 element tuples with layout ``[dx, dy, log(dw), log(dh)]``. **Required.**

* **4** : ``scores`` - tensor of type *T* with shape ``[num_batches, number_of_anchors, height, width]`` providing proposals scores. **Required.**
* **4** : ``scores`` - tensor of type *T* with shape ``[num_batches, number_of_anchors, height, width]``
providing proposals scores. **Required.**

The ``height`` and ``width`` from inputs ``anchors``, ``boxesdeltas`` and ``scores`` are the height and width of feature maps.
The ``height`` and ``width`` from inputs ``anchors``, ``boxesdeltas`` and
``scores`` are the height and width of feature maps.

**Outputs**

* **1** : ``rpnrois`` - tensor of type *T* with shape ``[num_rois, 4]`` providing proposed ROIs. The proposals are layouted as ``[xmin, ymin, xmax, ymax]``. The ``num_rois`` means the total proposals number of all the images in one batch. ``num_rois`` is a dynamic dimension.
* **1** : ``rpnrois`` - tensor of type *T* with shape ``[num_rois, 4]``
providing proposed ROIs. The proposals are layouted as ``[xmin, ymin, xmax, ymax]``. The ``num_rois`` means the total proposals number of all the images in one batch. ``num_rois`` is a dynamic dimension.

* **2** : ``rpnscores`` - tensor of type *T* with shape ``[num_rois]`` providing proposed ROIs scores.
* **2** : ``rpnscores`` - tensor of type *T* with shape ``[num_rois]``
providing proposed ROIs scores.

* **3** : ``rpnroisnum`` - tensor of type *roi_num_type* with shape ``[num_batches]`` providing the number of proposed ROIs in each image.
* **3** : ``rpnroisnum`` - tensor of type *roi_num_type* with shape
``[num_batches]`` providing the number of proposed ROIs in each image.

**Types**

Expand All @@ -139,43 +170,42 @@ The ``height`` and ``width`` from inputs ``anchors``, ``boxesdeltas`` and ``scor

.. ref-code-block:: cpp

<layer ... type="GenerateProposals" version="opset9">
<data min_size="0.0" nms_threshold="0.699999988079071" post_nms_count="1000" pre_nms_count="1000" roi_num_type="i32"/>
<input>
<port id="0">
<dim>8</dim>
<dim>3</dim>
</port>
<port id="1">
<dim>50</dim>
<dim>84</dim>
<dim>3</dim>
<dim>4</dim>
</port>
<port id="2">
<dim>8</dim>
<dim>12</dim>
<dim>50</dim>
<dim>84</dim>
</port>
<port id="3">
<dim>8</dim>
<dim>3</dim>
<dim>50</dim>
<dim>84</dim>
</port>
</input>
<output>
<port id="4" precision="FP32">
<dim>-1</dim>
<dim>4</dim>
</port>
<port id="5" precision="FP32">
<dim>-1</dim>
</port>
<port id="6" precision="I32">
<dim>8</dim>
</port>
</output>
</layer>

<layer ... type="GenerateProposals" version="opset9">
<data min_size="0.0" nms_threshold="0.699999988079071" post_nms_count="1000" pre_nms_count="1000" roi_num_type="i32"/>
<input>
<port id="0">
<dim>8</dim>
<dim>3</dim>
</port>
<port id="1">
<dim>50</dim>
<dim>84</dim>
<dim>3</dim>
<dim>4</dim>
</port>
<port id="2">
<dim>8</dim>
<dim>12</dim>
<dim>50</dim>
<dim>84</dim>
</port>
<port id="3">
<dim>8</dim>
<dim>3</dim>
<dim>50</dim>
<dim>84</dim>
</port>
</input>
<output>
<port id="4" precision="FP32">
<dim>-1</dim>
<dim>4</dim>
</port>
<port id="5" precision="FP32">
<dim>-1</dim>
</port>
<port id="6" precision="I32">
<dim>8</dim>
</port>
</output>
</layer>

0 comments on commit 9380842

Please sign in to comment.