예제 #1
0
    def GenerateProposals(self, blobs_in, blobs_out, anchors, spatial_scale):
        """Op for generating RPN porposals.

        blobs_in:
          - 'rpn_cls_probs': 4D tensor of shape (N, A, H, W), where N is the
            number of minibatch images, A is the number of anchors per
            locations, and (H, W) is the spatial size of the prediction grid.
            Each value represents a "probability of object" rating in [0, 1].
          - 'rpn_bbox_pred': 4D tensor of shape (N, 4 * A, H, W) of predicted
            deltas for transformation anchor boxes into RPN proposals.
          - 'im_info': 2D tensor of shape (N, 3) where the three columns encode
            the input image's [height, width, scale]. Height and width are
            for the input to the network, not the original image; scale is the
            scale factor used to scale the original image to the network input
            size.

        blobs_out:
          - 'rpn_rois': 2D tensor of shape (R, 5), for R RPN proposals where the
            five columns encode [batch ind, x1, y1, x2, y2]. The boxes are
            w.r.t. the network input, which is a *scaled* version of the
            original image; these proposals must be scaled by 1 / scale (where
            scale comes from im_info; see above) to transform it back to the
            original input image coordinate system.
          - 'rpn_roi_probs': 1D tensor of objectness probability scores
            (extracted from rpn_cls_probs; see above).
        """
        name = 'GenerateProposalsOp:' + ','.join([str(b) for b in blobs_in])
        # spatial_scale passed to the Python op is only used in convert_pkl_to_pb
        self.net.Python(
            GenerateProposalsOp(anchors, spatial_scale, self.train).forward)(
                blobs_in, blobs_out, name=name, spatial_scale=spatial_scale)
        return blobs_out
예제 #2
0
 def GenerateProposals(self, blobs_in, blobs_out, anchors, spatial_scale):
     # blobs_in = ['rpn_cls_probs', 'rpn_bbox_pred', 'im_info']
     # blobs_out = ['rpn_rois', 'rpn_roi_probs']
     name = 'GenerateProposalsOp:' + ','.join([str(b) for b in blobs_in])
     self.net.Python(
         GenerateProposalsOp(anchors, spatial_scale,
                             self.train).forward)(blobs_in,
                                                  blobs_out,
                                                  name=name)
     return blobs_out