B Babu
B Babu

Reputation: 61

I am trying to build a object detection using Mask RCNN and get an error when i call MaskRCNN method

I am trying to use matterport's keras implementation of Mask RCNN. When I call the function modellib.MaskRCNN, I get below error.

'''maskrcnnModel = modellib.MaskRCNN(mode='training', config=config, model_dir='/rootdir' )'''

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/type_spec.py in type_spec_from_value(value) 3, "Failed to convert %r to tensor: %s" % (type(value).name, e))

raise TypeError("Could not build a TypeSpec for %r with type %s" % (value, type(value).name)) TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) dtype=float32 (created by layer 'tf.math.truediv')> with type KerasTensor

I am using Tensorflow 2.4.1 and keras 2.4.0 version

I surfed at many places, but i did not work for me. I tried to modify the model.py as recommended in other stackoverflow questions, but i do not see any difference.

I appreciate your help

Upvotes: 2

Views: 3327

Answers (2)

Elvis Fontalvo
Elvis Fontalvo

Reputation: 1

Change in your model:

gt_boxes = KL.Lambda(lambda x: norm_boxes_graph(x, K.shape(input_image)[1:3]))(input_gt_boxes)

to

h, w = K.shape(input_image)[1], K.shape(input_image)[2]
image_scale = K.cast(K.stack([h, w, h, w], axis=0), tf.float32) 
gt_boxes = KL.Lambda(lambda x: K.cast(x, tf.float32))(input_gt_boxes)

works for tensorflow 2.3.1 and Python 3.8

Upvotes: 0

B Babu
B Babu

Reputation: 61

Finally after lot of surfing, I found another repository in github that helped me to move forward. I am able to move ahead to train the model. Thanks to akTwelve for the great work to update the matterport's base code to work for TF 2.4.1 and Kears 2.4.0. You can get the github link @ https://github.com/akTwelve/Mask_RCNN

Upvotes: 2

Related Questions