7

I can't seem to find a reliable version of Mask-RCNN for TensorFlow 2. The matterport mask-rcnn (https://github.com/matterport/Mask_RCNN) has depreciated Tensorflow 1 code. Does anyone know of TensorFlow 2 implementations of RCNN either based on matterport or something else, or other object detection models?

Juwonlo
  • 11
  • 6
myelin
  • 89
  • 1
  • 2

3 Answers3

3

There is one working implementation of Mask RCNN in TF 2+. I found it here: https://github.com/matterport/Mask_RCNN/tree/295c802f0bebbc4a34ec4855f4960a52a701271d

To make all examples work in TF 2.4 you must modify rcnn/model.py file by replacing:

if model.uses_learning_phase and not isinstance(K.learning_phase(), int):

with

if not isinstance(K.learning_phase(), int):

as uses_learning_phase doesn't work any more in TF 2.4.

Then use this correction: https://stackoverflow.com/a/66842506/13467454

It should work fine on TF 2.4.

paulo116
  • 168
  • 1
  • 8
2

Take a look at this port, it works for me. https://www.immersivelimit.com/tutorials/mask-rcnn-for-windows-10-tensorflow-2-cuda-101

There is also an implementation by Nvidia, I didn't try but seems to be serious: https://ngc.nvidia.com/catalog/resources/nvidia:mask_r_cnn_for_tensorflow2

1

A recent fork from Matterport's version has TF2 support: https://github.com/ahmedfgad/Mask-RCNN-TF2

TF Hub also has a convenient resource for Mask RCNN: https://hub.tensorflow.google.cn/tensorflow/mask_rcnn/inception_resnet_v2_1024x1024/1 Which can be used as simply as:

import tensorflow_hub as hub

# Apply image detector on a single image.
detector = hub.load("https://hub.tensorflow.google.cn/tensorflow/mask_rcnn/inception_resnet_v2_1024x1024/1")
detector_output = detector(image_tensor)
class_ids = detector_output["detection_classes"]
Roy Shilkrot
  • 3,079
  • 29
  • 25