Ejemplo n.º 1
0
    def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
        #[2000,5] [x1,y1,x2,y2] [2000,1]
        rois, rpn_scores = proposal_layer(\
                                        rpn_cls_prob, rpn_bbox_pred, self._im_info, self._mode,
                                         self._feat_stride, self._anchors, self._num_anchors)

        return rois, rpn_scores
Ejemplo n.º 2
0
    def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
        rois, rpn_scores = proposal_layer(rpn_cls_prob, rpn_bbox_pred,
                                          self._im_info, self._mode,
                                          self._feat_stride, self._anchors,
                                          self._num_anchors)

        return rois, rpn_scores
    def im_detect(self, im):
        blobs, im_scales = model_utils._get_blobs(im)
        assert len(im_scales) == 1, "Only single-image batch implemented"

        im_blob = blobs['data']
        blobs['im_info'] = np.array([[im_blob.shape[1], im_blob.shape[2], im_scales[0]]], dtype=np.float32)

        anchors, anchor_length = self.generate_anchors(blobs['im_info'])

        feed = { 
            self._images: blobs['data']
        }
        rpn_cls_prob, rpn_bbox_pred, rpn_feature_map = self.rpn_sess.run([self._rpn_cls_prob, self._rpn_bbox_pred, self._rpn_feature_map], feed)
        rois, _ = proposal_layer(rpn_cls_prob, rpn_bbox_pred, blobs['im_info'], 'TEST',
                                        self._feat_stride, anchors, self._num_anchors)
        rois = np.reshape(rois, [-1, 5])
        # rpn_scores = np.reshape(rpn_scores, [-1, 1])

        feed = {
            self._rcnn_feature_map: rpn_feature_map,
            self._rois: rois
        }
        scores, bbox_pred = self.rcnn_sess.run([self._cls_prob, self._bbox_pred], feed)
        
        boxes = rois[:, 1:5] / im_scales[0]
        scores = np.reshape(scores, [scores.shape[0], -1])
        bbox_pred = np.reshape(bbox_pred, [bbox_pred.shape[0], -1])
        # Apply bounding-box regression deltas
        box_deltas = bbox_pred
        pred_boxes = bbox_transform_inv(boxes, box_deltas)
        pred_boxes = self._clip_boxes(pred_boxes, im.shape)

        return scores, pred_boxes
Ejemplo n.º 4
0
    def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
        rois, rpn_scores = proposal_layer(\
                                        rpn_cls_prob, rpn_bbox_pred, self._im_info, self._mode,
                                         self._feat_stride, self._anchors, self._num_anchors, self._gt_boxes, self._gt_texts, self._gt_pair)
        #print(rois)

        return rois, rpn_scores
Ejemplo n.º 5
0
    def _proposal_layer(self, rpn_cls_prob, rpn_cls_a_prob, rpn_bbox_pred):
        # Training: proposal_layer取前分數前12000的box做nms後再挑前2000個分數高的box
        # Testing: proposal_layer取前分數前6000的box做nms後再挑前300個分數高的box
        rois, rpn_scores = proposal_layer(\
                                        rpn_cls_prob, rpn_cls_a_prob, rpn_bbox_pred, self._im_info, self._mode,
                                         self._feat_stride, self._anchors, self._num_anchors)

        return rois, rpn_scores
Ejemplo n.º 6
0
    def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred, name):
        with tf.variable_scope(name) as scope:
            rois, rpn_scores = proposal_layer(rpn_cls_prob, rpn_bbox_pred,
                                              self._im_info, self._mode,
                                              self._feat_stride, self._anchors,
                                              self._num_anchors)
            rois.set_shape([None, 5])
            rpn_scores.set_shape([None, 1])

        return rois, rpn_scores
Ejemplo n.º 7
0
 def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
     rois, rpn_scores = proposal_layer(\
                                     rpn_cls_prob.data.cpu().numpy(), rpn_bbox_pred.data.cpu().numpy(), self._im_info, self._mode,
                                      self._feat_stride, self._anchors, self._num_anchors)
     rois_, rpn_scores_ = proposal_layer_(\
                                     rpn_cls_prob, rpn_bbox_pred, self._im_info, self._mode,
                                      self._feat_stride, self._anchors, self._num_anchors)
     print((torch.Tensor(rois) - rois_.data.cpu()).max())
     print((torch.Tensor(rpn_scores) - rpn_scores_.data.cpu()).max())
     import utils.timer
     rois = rois_.data.cpu().numpy()
     rpn_scores = rpn_scores_.data.cpu().numpy()
     return rois, rpn_scores
Ejemplo n.º 8
0
  def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred, name):
    with tf.variable_scope(name) as scope:
      rois, rpn_scores = proposal_layer(
        rpn_cls_prob,
        rpn_bbox_pred,
        self._im_info,
        self._mode,
        self._feat_stride,
        self._anchors,
        self._num_anchors
      )
      rois.set_shape([None, 5])
      rpn_scores.set_shape([None, 1])

    return rois, rpn_scores
Ejemplo n.º 9
0
 def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
     rois, rpn_scores = proposal_layer(\
                                     rpn_cls_prob.data.cpu().numpy(), rpn_bbox_pred.data.cpu().numpy(), self._im_info, self._mode,
                                      self._feat_stride, self._anchors, self._num_anchors)
     return rois, rpn_scores
Ejemplo n.º 10
0
  def _proposal_layer(self, rpn_cls_prob, rpn_bbox_pred):
    rois, rpn_scores = proposal_layer(\
                                    rpn_cls_prob, rpn_bbox_pred, self._im_info, self._mode,
                                     self._feat_stride, self._anchors, self._num_anchors)

    return rois, rpn_scores