如何实现Mask R-CNN?

时间:2018-07-23 05:55:19

标签: android tensorflow object-detection image-masking tensorflow-android

试图在Android的Image中找出特定的对象蒙版。我使用Tensorflow使用Mask R-CNN训练了一个模块。现在,我要将其放入android,并需要图像蒙版。

link中可以使用android中的Tensorflow对象检测。

但是如何在android中获取图像蒙版?

使用以下代码在python中进行掩码检测。

if 'detection_masks' in tensor_dict:
    # The following processing is only for single image
    detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0])
    detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0])
    # Reframe is required to translate mask from box coordinates to image coordinates and fit the image size.
    real_num_detection = tf.cast(tensor_dict['num_detections'][0], tf.int32)
    detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1])
    detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1])
    detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(
        detection_masks, detection_boxes, image.shape[0], image.shape[1])
    detection_masks_reframed = tf.cast(
        tf.greater(detection_masks_reframed, 0.5), tf.uint8)
    # Follow the convention by adding back the batch dimension
    tensor_dict['detection_masks'] = tf.expand_dims(detection_masks_reframed, 0)

但是如何将其转换为android ??

有谁可以帮忙?

谢谢。

0 个答案:

没有答案