matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.53k stars 11.68k forks source link

ValueError: Exception encountered when calling layer "mrcnn_bbox" (type Reshape). #3047

Open liaokaiyao opened 1 month ago

liaokaiyao commented 1 month ago

Error creating MaskRCNN model: Exception encountered when calling layer "mrcnn_bbox" (type Reshape).

Tried to convert 'shape' to a tensor and failed. Error: None values not supported.

Call arguments received by layer "mrcnn_bbox" (type Reshape): • inputs=tf.Tensor(shape=(1, None, 324), dtype=float32) Traceback (most recent call last): File "test.py", line 67, in model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config) File "/home/chenx2/liao/mrcnn/mrcnn/model.py", line 1839, in init self.keras_model = self.build(mode=mode, config=config) File "/home/chenx2/liao/mrcnn/mrcnn/model.py", line 2037, in build fpn_classifier_graph(rpn_rois, mrcnn_feature_maps, input_image_meta, File "/home/chenx2/liao/mrcnn/mrcnn/model.py", line 953, in fpn_classifier_graph mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x) File "/home/chenx2/miniconda3/envs/igibson1/lib/python3.8/site-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "/home/chenx2/miniconda3/envs/igibson1/lib/python3.8/site-packages/tensorflow/python/framework/op_def_library.py", line 571, in _ExtractInputsAndAttrs raise ValueError( ValueError: Exception encountered when calling layer "mrcnn_bbox" (type Reshape).

Tried to convert 'shape' to a tensor and failed. Error: None values not supported.

Call arguments received by layer "mrcnn_bbox" (type Reshape): • inputs=tf.Tensor(shape=(1, None, 324), dtype=float32)

518789Adf commented 1 week ago

s = K.int_shape(x) if s[1]==None: mrcnn_bbox = KL.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x) else:
mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x)