distribute_fpn_proposals

paddle.vision.ops. distribute_fpn_proposals ( fpn_rois, min_level, max_level, refer_level, refer_scale, pixel_offset=False, rois_num=None, name=None ) [source]

In Feature Pyramid Networks (FPN) models, it is needed to distribute

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.distribute_fpn_proposals, line 2)

Block quote ends without a blank line; unexpected unindent.

all proposals into different FPN level, with respect to scale of the proposals, the referring scale and the referring level. Besides, to restore the order of proposals, we return an array which indicates the original index of rois in current proposals. To compute FPN level for each roi, the formula is given as follows:

\[\begin{split}roi\_scale &= \sqrt{BBoxArea(fpn\_roi)} level = floor(&\log(\\frac{roi\_scale}{refer\_scale}) + refer\_level)\end{split}\]

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/vision/ops.py:docstring of paddle.vision.ops.distribute_fpn_proposals, line 10)

Explicit markup ends without a blank line; unexpected unindent.

where BBoxArea is a function to compute the area of each roi.

Parameters
  • fpn_rois (Tensor) – The input fpn_rois. 2-D Tensor with shape [N, 4] and data type can be float32 or float64.

  • min_level (int) – The lowest level of FPN layer where the proposals come from.

  • max_level (int) – The highest level of FPN layer where the proposals come from.

  • refer_level (int) – The referring level of FPN layer with specified scale.

  • refer_scale (int) – The referring scale of FPN layer with specified level.

  • pixel_offset (bool, optional) – Whether there is pixel offset. If True, the offset of image shape will be 1. ‘False’ by default.

  • rois_num (Tensor, optional) – 1-D Tensor contains the number of RoIs in each image. The shape is [B] and data type is int32. B is the number of images. If rois_num not None, it will return a list of 1-D Tensor. Each element is the output RoIs’ number of each image on the corresponding level and the shape is [B]. None by default.

  • name (str, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.

Returns

The proposals in each FPN level. It is a list of 2-D Tensor with shape [M, 4], where M is

and data type is same as fpn_rois . The length is max_level-min_level+1.

restore_ind (Tensor): The index used to restore the order of fpn_rois. It is a 2-D Tensor with shape [N, 1]

, where N is the number of total rois. The data type is int32.

rois_num_per_level (List): A list of 1-D Tensor and each Tensor is

the RoIs’ number in each image on the corresponding level. The shape is [B] and data type of int32, where B is the number of images.

Return type

multi_rois (List)

Examples

import paddle

fpn_rois = paddle.rand((10, 4))
rois_num = paddle.to_tensor([3, 1, 4, 2], dtype=paddle.int32)

multi_rois, restore_ind, rois_num_per_level = paddle.vision.ops.distribute_fpn_proposals(
    fpn_rois=fpn_rois,
    min_level=2,
    max_level=5,
    refer_level=4,
    refer_scale=224,
    rois_num=rois_num)