TensorFlow 2 Mask-RCNN?

Viewed 6834

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 or other object detection models? Or possibly a stable Docker image that will work with Matterport?

3 Answers

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.

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"]
Related