def generate_proposals(scores, bbox_deltas, im_info, anchors, variances, pre_nms_top_n=6000, post_nms_top_n=1000, nms_thresh=0.5, min_size=0.1, eta=1.0, name=None, return_rois_num=False):
    "\n\t:alias_main: paddle.nn.functional.generate_proposals\n\t:alias: paddle.nn.functional.generate_proposals,paddle.nn.functional.vision.generate_proposals\n\t:old_api: paddle.fluid.layers.generate_proposals\n\n    **Generate proposal Faster-RCNN**\n\n    This operation proposes RoIs according to each box with their\n    probability to be a foreground object and \n    the box can be calculated by anchors. Bbox_deltais and scores\n    to be an object are the output of RPN. Final proposals\n    could be used to train detection net.\n\n    For generating proposals, this operation performs following steps:\n\n    1. Transposes and resizes scores and bbox_deltas in size of\n       (H*W*A, 1) and (H*W*A, 4)\n    2. Calculate box locations as proposals candidates. \n    3. Clip boxes to image\n    4. Remove predicted boxes with small area. \n    5. Apply NMS to get final proposals as output.\n\n    Args:\n        scores(Variable): A 4-D Tensor with shape [N, A, H, W] represents\n            the probability for each box to be an object.\n            N is batch size, A is number of anchors, H and W are height and\n            width of the feature map. The data type must be float32.\n        bbox_deltas(Variable): A 4-D Tensor with shape [N, 4*A, H, W]\n            represents the difference between predicted box location and\n            anchor location. The data type must be float32.\n        im_info(Variable): A 2-D Tensor with shape [N, 3] represents origin\n            image information for N batch. Height and width are the input sizes \n            and scale is the ratio of network input size and original size. \n            The data type can be float32 or float64.\n        anchors(Variable):   A 4-D Tensor represents the anchors with a layout\n            of [H, W, A, 4]. H and W are height and width of the feature map,\n            num_anchors is the box count of each position. Each anchor is\n            in (xmin, ymin, xmax, ymax) format an unnormalized. The data type must be float32.\n        variances(Variable): A 4-D Tensor. The expanded variances of anchors with a layout of\n            [H, W, num_priors, 4]. Each variance is in\n            (xcenter, ycenter, w, h) format. The data type must be float32.\n        pre_nms_top_n(float): Number of total bboxes to be kept per\n            image before NMS. The data type must be float32. `6000` by default.\n        post_nms_top_n(float): Number of total bboxes to be kept per\n            image after NMS. The data type must be float32. `1000` by default.\n        nms_thresh(float): Threshold in NMS. The data type must be float32. `0.5` by default.\n        min_size(float): Remove predicted boxes with either height or\n            width < min_size. The data type must be float32. `0.1` by default.\n        eta(float): Apply in adaptive NMS, if adaptive `threshold > 0.5`,\n            `adaptive_threshold = adaptive_threshold * eta` in each iteration.\n        return_rois_num(bool): When setting True, it will return a 1D Tensor with shape [N, ] that includes Rois's \n            num of each image in one batch. The N is the image's num. For example, the tensor has values [4,5] that represents\n            the first image has 4 Rois, the second image has 5 Rois. It only used in rcnn model. \n            'False' by default. \n    Returns:\n        tuple:\n        A tuple with format ``(rpn_rois, rpn_roi_probs)``.\n\n        - **rpn_rois**: The generated RoIs. 2-D Tensor with shape ``[N, 4]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.\n        - **rpn_roi_probs**: The scores of generated RoIs. 2-D Tensor with shape ``[N, 1]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.\n\n    Examples:\n        .. code-block:: python\n        \n            import paddle.fluid as fluid\n            scores = fluid.data(name='scores', shape=[None, 4, 5, 5], dtype='float32')\n            bbox_deltas = fluid.data(name='bbox_deltas', shape=[None, 16, 5, 5], dtype='float32')\n            im_info = fluid.data(name='im_info', shape=[None, 3], dtype='float32')\n            anchors = fluid.data(name='anchors', shape=[None, 5, 4, 4], dtype='float32')\n            variances = fluid.data(name='variances', shape=[None, 5, 10, 4], dtype='float32')\n            rois, roi_probs = fluid.layers.generate_proposals(scores, bbox_deltas,\n                         im_info, anchors, variances)\n\n    "
    helper = LayerHelper('generate_proposals', **locals())
    check_variable_and_dtype(scores, 'scores', ['float32'], 'generate_proposals')
    check_variable_and_dtype(bbox_deltas, 'bbox_deltas', ['float32'], 'generate_proposals')
    check_variable_and_dtype(im_info, 'im_info', ['float32', 'float64'], 'generate_proposals')
    check_variable_and_dtype(anchors, 'anchors', ['float32'], 'generate_proposals')
    check_variable_and_dtype(variances, 'variances', ['float32'], 'generate_proposals')
    rpn_rois = helper.create_variable_for_type_inference(dtype=bbox_deltas.dtype)
    rpn_roi_probs = helper.create_variable_for_type_inference(dtype=scores.dtype)
    rpn_rois_lod = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='generate_proposals', inputs={'Scores': scores, 'BboxDeltas': bbox_deltas, 'ImInfo': im_info, 'Anchors': anchors, 'Variances': variances}, attrs={'pre_nms_topN': pre_nms_top_n, 'post_nms_topN': post_nms_top_n, 'nms_thresh': nms_thresh, 'min_size': min_size, 'eta': eta}, outputs={'RpnRois': rpn_rois, 'RpnRoiProbs': rpn_roi_probs, 'RpnRoisLod': rpn_rois_lod})
    rpn_rois.stop_gradient = True
    rpn_roi_probs.stop_gradient = True
    rpn_rois_lod.stop_gradient = True
    if return_rois_num:
        return (rpn_rois, rpn_roi_probs, rpn_rois_lod)
    else:
        return (rpn_rois, rpn_roi_probs)
:alias_main: paddle.nn.functional.generate_proposals
    :alias: paddle.nn.functional.generate_proposals,paddle.nn.functional.vision.generate_proposals
    :old_api: paddle.fluid.layers.generate_proposals

**Generate proposal Faster-RCNN**

This operation proposes RoIs according to each box with their
probability to be a foreground object and 
the box can be calculated by anchors. Bbox_deltais and scores
to be an object are the output of RPN. Final proposals
could be used to train detection net.

For generating proposals, this operation performs following steps:

1. Transposes and resizes scores and bbox_deltas in size of
   (H*W*A, 1) and (H*W*A, 4)
2. Calculate box locations as proposals candidates. 
3. Clip boxes to image
4. Remove predicted boxes with small area. 
5. Apply NMS to get final proposals as output.

Args:
    scores(Variable): A 4-D Tensor with shape [N, A, H, W] represents
        the probability for each box to be an object.
        N is batch size, A is number of anchors, H and W are height and
        width of the feature map. The data type must be float32.
    bbox_deltas(Variable): A 4-D Tensor with shape [N, 4*A, H, W]
        represents the difference between predicted box location and
        anchor location. The data type must be float32.
    im_info(Variable): A 2-D Tensor with shape [N, 3] represents origin
        image information for N batch. Height and width are the input sizes 
        and scale is the ratio of network input size and original size. 
        The data type can be float32 or float64.
    anchors(Variable):   A 4-D Tensor represents the anchors with a layout
        of [H, W, A, 4]. H and W are height and width of the feature map,
        num_anchors is the box count of each position. Each anchor is
        in (xmin, ymin, xmax, ymax) format an unnormalized. The data type must be float32.
    variances(Variable): A 4-D Tensor. The expanded variances of anchors with a layout of
        [H, W, num_priors, 4]. Each variance is in
        (xcenter, ycenter, w, h) format. The data type must be float32.
    pre_nms_top_n(float): Number of total bboxes to be kept per
        image before NMS. The data type must be float32. `6000` by default.
    post_nms_top_n(float): Number of total bboxes to be kept per
        image after NMS. The data type must be float32. `1000` by default.
    nms_thresh(float): Threshold in NMS. The data type must be float32. `0.5` by default.
    min_size(float): Remove predicted boxes with either height or
        width < min_size. The data type must be float32. `0.1` by default.
    eta(float): Apply in adaptive NMS, if adaptive `threshold > 0.5`,
        `adaptive_threshold = adaptive_threshold * eta` in each iteration.
    return_rois_num(bool): When setting True, it will return a 1D Tensor with shape [N, ] that includes Rois's 
        num of each image in one batch. The N is the image's num. For example, the tensor has values [4,5] that represents
        the first image has 4 Rois, the second image has 5 Rois. It only used in rcnn model. 
        'False' by default. 
Returns:
    tuple:
    A tuple with format ``(rpn_rois, rpn_roi_probs)``.

    - **rpn_rois**: The generated RoIs. 2-D Tensor with shape ``[N, 4]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.
    - **rpn_roi_probs**: The scores of generated RoIs. 2-D Tensor with shape ``[N, 1]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.

Examples:
    .. code-block:: python
    
        import paddle.fluid as fluid
        scores = fluid.data(name='scores', shape=[None, 4, 5, 5], dtype='float32')
        bbox_deltas = fluid.data(name='bbox_deltas', shape=[None, 16, 5, 5], dtype='float32')
        im_info = fluid.data(name='im_info', shape=[None, 3], dtype='float32')
        anchors = fluid.data(name='anchors', shape=[None, 5, 4, 4], dtype='float32')
        variances = fluid.data(name='variances', shape=[None, 5, 10, 4], dtype='float32')
        rois, roi_probs = fluid.layers.generate_proposals(scores, bbox_deltas,
                     im_info, anchors, variances)
def generate_proposals(scores, bbox_deltas, im_info, anchors, variances, pre_nms_top_n=6000, post_nms_top_n=1000, nms_thresh=0.5, min_size=0.1, eta=1.0, name=None, return_rois_num=False):
    "\n\t:alias_main: paddle.nn.functional.generate_proposals\n\t:alias: paddle.nn.functional.generate_proposals,paddle.nn.functional.vision.generate_proposals\n\t:old_api: paddle.fluid.layers.generate_proposals\n\n    **Generate proposal Faster-RCNN**\n\n    This operation proposes RoIs according to each box with their\n    probability to be a foreground object and \n    the box can be calculated by anchors. Bbox_deltais and scores\n    to be an object are the output of RPN. Final proposals\n    could be used to train detection net.\n\n    For generating proposals, this operation performs following steps:\n\n    1. Transposes and resizes scores and bbox_deltas in size of\n       (H*W*A, 1) and (H*W*A, 4)\n    2. Calculate box locations as proposals candidates. \n    3. Clip boxes to image\n    4. Remove predicted boxes with small area. \n    5. Apply NMS to get final proposals as output.\n\n    Args:\n        scores(Variable): A 4-D Tensor with shape [N, A, H, W] represents\n            the probability for each box to be an object.\n            N is batch size, A is number of anchors, H and W are height and\n            width of the feature map. The data type must be float32.\n        bbox_deltas(Variable): A 4-D Tensor with shape [N, 4*A, H, W]\n            represents the difference between predicted box location and\n            anchor location. The data type must be float32.\n        im_info(Variable): A 2-D Tensor with shape [N, 3] represents origin\n            image information for N batch. Height and width are the input sizes \n            and scale is the ratio of network input size and original size. \n            The data type can be float32 or float64.\n        anchors(Variable):   A 4-D Tensor represents the anchors with a layout\n            of [H, W, A, 4]. H and W are height and width of the feature map,\n            num_anchors is the box count of each position. Each anchor is\n            in (xmin, ymin, xmax, ymax) format an unnormalized. The data type must be float32.\n        variances(Variable): A 4-D Tensor. The expanded variances of anchors with a layout of\n            [H, W, num_priors, 4]. Each variance is in\n            (xcenter, ycenter, w, h) format. The data type must be float32.\n        pre_nms_top_n(float): Number of total bboxes to be kept per\n            image before NMS. The data type must be float32. `6000` by default.\n        post_nms_top_n(float): Number of total bboxes to be kept per\n            image after NMS. The data type must be float32. `1000` by default.\n        nms_thresh(float): Threshold in NMS. The data type must be float32. `0.5` by default.\n        min_size(float): Remove predicted boxes with either height or\n            width < min_size. The data type must be float32. `0.1` by default.\n        eta(float): Apply in adaptive NMS, if adaptive `threshold > 0.5`,\n            `adaptive_threshold = adaptive_threshold * eta` in each iteration.\n        return_rois_num(bool): When setting True, it will return a 1D Tensor with shape [N, ] that includes Rois's \n            num of each image in one batch. The N is the image's num. For example, the tensor has values [4,5] that represents\n            the first image has 4 Rois, the second image has 5 Rois. It only used in rcnn model. \n            'False' by default. \n    Returns:\n        tuple:\n        A tuple with format ``(rpn_rois, rpn_roi_probs)``.\n\n        - **rpn_rois**: The generated RoIs. 2-D Tensor with shape ``[N, 4]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.\n        - **rpn_roi_probs**: The scores of generated RoIs. 2-D Tensor with shape ``[N, 1]`` while ``N`` is the number of RoIs. The data type is the same as ``scores``.\n\n    Examples:\n        .. code-block:: python\n        \n            import paddle.fluid as fluid\n            scores = fluid.data(name='scores', shape=[None, 4, 5, 5], dtype='float32')\n            bbox_deltas = fluid.data(name='bbox_deltas', shape=[None, 16, 5, 5], dtype='float32')\n            im_info = fluid.data(name='im_info', shape=[None, 3], dtype='float32')\n            anchors = fluid.data(name='anchors', shape=[None, 5, 4, 4], dtype='float32')\n            variances = fluid.data(name='variances', shape=[None, 5, 10, 4], dtype='float32')\n            rois, roi_probs = fluid.layers.generate_proposals(scores, bbox_deltas,\n                         im_info, anchors, variances)\n\n    "
    helper = LayerHelper('generate_proposals', **locals())
    check_variable_and_dtype(scores, 'scores', ['float32'], 'generate_proposals')
    check_variable_and_dtype(bbox_deltas, 'bbox_deltas', ['float32'], 'generate_proposals')
    check_variable_and_dtype(im_info, 'im_info', ['float32', 'float64'], 'generate_proposals')
    check_variable_and_dtype(anchors, 'anchors', ['float32'], 'generate_proposals')
    check_variable_and_dtype(variances, 'variances', ['float32'], 'generate_proposals')
    rpn_rois = helper.create_variable_for_type_inference(dtype=bbox_deltas.dtype)
    rpn_roi_probs = helper.create_variable_for_type_inference(dtype=scores.dtype)
    rpn_rois_lod = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='generate_proposals', inputs={'Scores': scores, 'BboxDeltas': bbox_deltas, 'ImInfo': im_info, 'Anchors': anchors, 'Variances': variances}, attrs={'pre_nms_topN': pre_nms_top_n, 'post_nms_topN': post_nms_top_n, 'nms_thresh': nms_thresh, 'min_size': min_size, 'eta': eta}, outputs={'RpnRois': rpn_rois, 'RpnRoiProbs': rpn_roi_probs, 'RpnRoisLod': rpn_rois_lod})
    rpn_rois.stop_gradient = True
    rpn_roi_probs.stop_gradient = True
    rpn_rois_lod.stop_gradient = True
    if return_rois_num:
        return (rpn_rois, rpn_roi_probs, rpn_rois_lod)
    else:
        return (rpn_rois, rpn_roi_probs)