def _unmold_single_detection(self, detections, img_meta):
        zero_ix = tf.where(tf.not_equal(detections[:, 4], 0))
        detections = tf.gather_nd(detections, zero_ix)

        # Extract boxes, class_ids, scores, and class-specific masks
        boxes = detections[:, :4]
        class_ids = tf.cast(detections[:, 4], tf.int32)
        scores = detections[:, 5]

        boxes = transforms.bbox_mapping_back(boxes, img_meta)

        return {'rois': boxes.numpy(),
                'class_ids': class_ids.numpy(),
                'scores': scores.numpy()}
Beispiel #2
0
    def _unmold_single_detection(self, detections, img_meta):
        # detections: [最终保留的框的个数, [y1, x1, y2, x2, class_id, score]]

        zero_ix = tf.where(tf.not_equal(detections[:, 4], 0))

        # detections: [分类结果为前景的框的个数, [y1, x1, y2, x2, class_id, score]]
        detections = tf.gather_nd(detections, zero_ix)

        # boxes: [分类结果为前景的框的个数, [y1, x1, y2, x2]]
        # class_ids: [分类结果为前景的框的个数,]
        # scores: [分类结果为前景的框的个数,]
        boxes = detections[:, :4]
        class_ids = tf.cast(detections[:, 4], tf.int32)
        scores = detections[:, 5]

        boxes = transforms.bbox_mapping_back(boxes, img_meta)

        return {'rois': boxes.numpy(),
                'class_ids': class_ids.numpy(),
                'scores': scores.numpy()}