parameters: (rpn_cls_prob, rpn_bbox_pred, im_info, cfg_key, _feat_stride, anchors, anchor_scales)
return_statement: return blob, scores
docstring: A simplified version compared to fast/er RCNN
       For details please see the technical report
docstring_summary: A simplified version compared to fast/er RCNN
       For details please see the technical report
docstring_tokens: A simplified version compared to fast / er RCNN For details please see the technical report
function: def proposal_layer(rpn_cls_prob, rpn_bbox_pred, im_info, cfg_key, _feat_stride, anchors, anchor_scales):
    """A simplified version compared to fast/er RCNN
       For details please see the technical report
    """
    pre_nms_topN  = cfg[cfg_key].RPN_PRE_NMS_TOP_N
    post_nms_topN = cfg[cfg_key].RPN_POST_NMS_TOP_N
    nms_thresh  = cfg[cfg_key].RPN_NMS_THRESH
  
    scales = np.array(anchor_scales)
    num_anchors = scales.shape[0] * 3
    im_info = im_info[0]
  
    # Get the scores and bounding boxes
    scores = rpn_cls_prob[:, :, :, num_anchors:]
    rpn_bbox_pred = rpn_bbox_pred.reshape((-1, 4))
    scores = scores.reshape((-1, 1))
    proposals = bbox_transform_inv(anchors, rpn_bbox_pred)
    proposals = clip_boxes(proposals, im_info[:2])
  
    # Pick the top region proposals
    order = scores.ravel().argsort()[::-1]
    if pre_nms_topN > 0:
      order = order[:pre_nms_topN]
    proposals = proposals[order, :]
    scores = scores[order]
  
    # Non-maximal suppression
    keep = nms(np.hstack((proposals, scores)), nms_thresh)
  
    # Pick th top region proposals after NMS
    if post_nms_topN > 0:
      keep = keep[:post_nms_topN]
    proposals = proposals[keep, :]
    scores = scores[keep]
    
    # Only support single image as input
    batch_inds = np.zeros((proposals.shape[0], 1), dtype=np.float32)
    blob = np.hstack((batch_inds, proposals.astype(np.float32, copy=False)))
  
    return blob, scores
function_tokens: def proposal_layer ( rpn_cls_prob , rpn_bbox_pred , im_info , cfg_key , _feat_stride , anchors , anchor_scales ) : pre_nms_topN = cfg [ cfg_key ] . RPN_PRE_NMS_TOP_N post_nms_topN = cfg [ cfg_key ] . RPN_POST_NMS_TOP_N nms_thresh = cfg [ cfg_key ] . RPN_NMS_THRESH scales = np . array ( anchor_scales ) num_anchors = scales . shape [ 0 ] * 3 im_info = im_info [ 0 ] # Get the scores and bounding boxes scores = rpn_cls_prob [ : , : , : , num_anchors : ] rpn_bbox_pred = rpn_bbox_pred . reshape ( ( - 1 , 4 ) ) scores = scores . reshape ( ( - 1 , 1 ) ) proposals = bbox_transform_inv ( anchors , rpn_bbox_pred ) proposals = clip_boxes ( proposals , im_info [ : 2 ] ) # Pick the top region proposals order = scores . ravel ( ) . argsort ( ) [ : : - 1 ] if pre_nms_topN > 0 : order = order [ : pre_nms_topN ] proposals = proposals [ order , : ] scores = scores [ order ] # Non-maximal suppression keep = nms ( np . hstack ( ( proposals , scores ) ) , nms_thresh ) # Pick th top region proposals after NMS if post_nms_topN > 0 : keep = keep [ : post_nms_topN ] proposals = proposals [ keep , : ] scores = scores [ keep ] # Only support single image as input batch_inds = np . zeros ( ( proposals . shape [ 0 ] , 1 ) , dtype = np . float32 ) blob = np . hstack ( ( batch_inds , proposals . astype ( np . float32 , copy = False ) ) ) return blob , scores