collect_fpn_proposals¶
- paddle.fluid.layers.detection. collect_fpn_proposals ( multi_rois, multi_scores, min_level, max_level, post_nms_top_n, rois_num_per_level=None, name=None ) [source]
-
This OP only supports LoDTensor as input. Concat multi-level RoIs (Region of Interest) and select N RoIs with respect to multi_scores. This operation performs the following steps:
Choose num_level RoIs and scores as input: num_level = max_level - min_level
Concat multi-level RoIs and scores
Sort scores and select post_nms_top_n scores
Gather RoIs by selected indices from scores
Re-sort RoIs by corresponding batch_id
- Parameters
-
multi_rois (list) – List of RoIs to collect. Element in list is 2-D LoDTensor with shape [N, 4] and data type is float32 or float64, N is the number of RoIs.
multi_scores (list) – List of scores of RoIs to collect. Element in list is 2-D LoDTensor with shape [N, 1] and data type is float32 or float64, N is the number of RoIs.
min_level (int) – The lowest level of FPN layer to collect
max_level (int) – The highest level of FPN layer to collect
post_nms_top_n (int) – The number of selected RoIs
rois_num_per_level (list, optional) – The List of RoIs’ numbers. Each element is 1-D Tensor which contains the RoIs’ number of each image on each level and the shape is [B] and data type is int32, B is the number of images. If it is not None then return a 1-D Tensor contains the output RoIs’ number of each image and the shape is [B]. Default: None
name (str, optional) – For detailed information, please refer to Name. Usually name is no need to set and None by default.
- Returns
-
fpn_rois(Variable): 2-D LoDTensor with shape [N, 4] and data type is float32 or float64. Selected RoIs.
rois_num(Tensor): 1-D Tensor contains the RoIs’s number of each image. The shape is [B] and data type is int32. B is the number of images.
- Return type
-
Variable
Examples
import paddle.fluid as fluid import paddle paddle.enable_static() multi_rois = [] multi_scores = [] for i in range(4): multi_rois.append(fluid.data( name='roi_'+str(i), shape=[None, 4], dtype='float32', lod_level=1)) for i in range(4): multi_scores.append(fluid.data( name='score_'+str(i), shape=[None, 1], dtype='float32', lod_level=1)) fpn_rois = fluid.layers.collect_fpn_proposals( multi_rois=multi_rois, multi_scores=multi_scores, min_level=2, max_level=5, post_nms_top_n=2000)