class_docstr: Proposal layer takes as input:
  (1) output of RPN cls_score
  (2) output of RPN bbox regression
  
  Converts that to an output ROIs
  (5, num_ROIs) <- [image_idx, x_min, y_min, x_max, y_max]
  
  Steps:
  1. For each anchor, generate anchor boxes and apply bbox deltas to get
     bbox proposals
  2. Clip bboxes to image
  3. remove bbox with H < threshold or W < threshold
  4. set the scores to be -1 for the padded area
  5. Take top pre_nms_N scores
  6. apply NMS with a threshold
  7. return the top num_ROIs proposals
  8. provide ROIs
  9. compute bbox targets and store in target_buffers
class_docstr_tok: ["Proposal","layer","takes","as","input",":","(","1",")","output","of","RPN","cls_score","(","2",")","output","of","RPN","bbox","regression","Converts","that","to","an","output","ROIs","(","5",",","num_ROIs",")","<","-","[","image_idx",",","x_min",",","y_min",",","x_max",",","y_max","]","Steps",":","1",".","For","each","anchor",",","generate","anchor","boxes","and","apply","bbox","deltas","to","get","bbox","proposals","2",".","Clip","bboxes","to","image","3.","remove","bbox","with","H","<","threshold","or","W","<","threshold","4.","set","the","scores","to","be","-1","for","the","padded","area","5",".","Take","top","pre_nms_N","scores","6.","apply","NMS","with","a","threshold","7.","return","the","top","num_ROIs","proposals","8.","provide","ROIs","9.","compute","bbox","targets","and","store","in","target_buffers"]
code: def allocate(self):
      super(ProposalLayer, self).allocate()
  
      # internal buffer to store transformed proposals
      self._proposals = self.be.zeros((self._num_anchors, 4))
  
      # to store the detections (scores + proposals)
      self.dets = self.be.zeros((self.pre_nms_N, 5))
  
      # buffer to store proposals after they have sorted
      # and filtered with NMS.
      # Note: The buffer has shape (num_ROIs, 5), where each column
      # is (0, x_min, y_min, x_max, y_max)
      # This format is designed to be compatible with the
      # roi-pooling layer fprop code from Fast-RCNN.
      self.dev_proposals = self.be.zeros((self.post_nms_N, 5))
  
      # buffer to store proposals after they have been sampled.
      # this is passed forward during training.
      self.dev_proposals_filtered = self.be.zeros((self.num_rois, 5))
  
      # class member as a view to get scores from RPN outputs
      self.rpn_scores_v = None
      self.bbox_deltas_v = None
  
      # create a local buffer for the rpn scores, otherwise, any in-place
      # memory change will affect the final cost and training
      self._scores = self.be.zeros((self._num_anchors, 1))
  
imports: from __future__ import division
  import numpy
  from neon.layers.layer import Layer
  from generate_anchors import generate_all_anchors
  from util import compute_targets, calculate_bb_overlap
label_desc: Use image node_id 4 for calling the ProposalLayer obj's underlying member method code with example usage: obj.allocate() without return types