Closed knagasaka closed 2 years ago
The error solved. Thank you.
The error solved. Thank you.
Hey! I have a similar problem, how did you solve it?
@knagasaka
@patrykGawron Hi, I do not remember very well, but I downgraded python to 3.6.13 and tensorflow to 1.5.0. I hope this helps you.
When I was trying Mask R-CNN Demo, I got valueerror after running kernel below.
model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config) model.load_weights(COCO_MODEL_PATH, by_name=True)
Error I got is below.
ValueError Traceback (most recent call last) Input In [3], in <cell line: 2>() 1 # Create model object in inference mode. ----> 2 model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config) 4 # Load weights trained on MS-COCO 5 model.load_weights(COCO_MODEL_PATH, by_name=True)
File ~/Mask_RCNN/mrcnn/model.py:1838, in MaskRCNN.init(self, mode, config, model_dir) 1836 self.model_dir = model_dir 1837 self.set_log_dir() -> 1838 self.keras_model = self.build(mode=mode, config=config)
File ~/Mask_RCNN/mrcnn/model.py:2044, in MaskRCNN.build(self, mode, config) 2035 mrcnn_class_logits, mrcnn_class, mrcnn_bbox =\ 2036 fpn_classifier_graph(rpn_rois, mrcnn_feature_maps, input_image_meta, 2037 config.POOL_SIZE, config.NUM_CLASSES, 2038 train_bn=config.TRAIN_BN, 2039 fc_layers_size=config.FPN_CLASSIF_FC_LAYERS_SIZE) 2041 # Detections 2042 # output is [batch, num_detections, (y1, x1, y2, x2, class_id, score)] in 2043 # normalized coordinates -> 2044 detections = DetectionLayer(config, name="mrcnn_detection")( 2045 [rpn_rois, mrcnn_class, mrcnn_bbox, input_image_meta]) 2047 # Create masks for detections 2048 detection_boxes = KL.Lambda(lambda x: x[..., :4])(detections)
File ~/.conda/envs/mask-rcnn/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py:951, in Layer.call(self, *args, **kwargs) 945 # Functional Model construction mode is invoked when
Layer
s are called on 946 # symbolicKerasTensor
s, i.e.: 947 # >> inputs = tf.keras.Input(10) 948 # >> outputs = MyLayer()(inputs) # Functional construction mode. 949 # >> model = tf.keras.Model(inputs, outputs) 950 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list): --> 951 return self._functional_construction_call(inputs, args, kwargs, 952 input_list) 954 # Maintains info about theLayer.call
stack. 955 call_context = base_layer_utils.call_context()File ~/.conda/envs/mask-rcnn/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py:1090, in Layer._functional_construction_call(self, inputs, args, kwargs, input_list) 1086 if keras_tensor.keras_tensors_enabled(): 1087 with call_context.enter( 1088 layer=self, inputs=inputs, build_graph=True, training=training_value): 1089 # Check input assumptions set after layer building, e.g. input shape. -> 1090 outputs = self._keras_tensor_symbolic_call( 1091 inputs, input_masks, args, kwargs) 1093 if outputs is None: 1094 raise ValueError('A layer\'s
call
method should return a ' 1095 'Tensor or a list of Tensors, not None ' 1096 '(layer: ' + self.name + ').')File ~/.conda/envs/mask-rcnn/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py:822, in Layer._keras_tensor_symbolic_call(self, inputs, input_masks, args, kwargs) 820 return nest.map_structure(keras_tensor.KerasTensor, output_signature) 821 else: --> 822 return self._infer_output_signature(inputs, args, kwargs, input_masks)
File ~/.conda/envs/mask-rcnn/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py:863, in Layer._infer_output_signature(self, inputs, args, kwargs, input_masks) 857 with autocast_variable.enable_auto_cast_variables( 858 self._compute_dtype_object): 859 # Build layer if applicable (if the
build
method has been 860 # overridden). 861 # TODO(kaftan): do we maybe_build here, or have we already done it? 862 self._maybe_build(inputs) --> 863 outputs = call_fn(inputs, *args, **kwargs) 865 self._handle_activity_regularization(inputs, outputs) 866 self._set_mask_metadata(inputs, outputs, input_masks, 867 build_graph=False)File ~/.conda/envs/mask-rcnn/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py:670, in convert..decorator..wrapper(*args, **kwargs)
668 except Exception as e: # pylint:disable=broad-except
669 if hasattr(e, 'ag_error_metadata'):
--> 670 raise e.ag_error_metadata.to_exception(e)
671 else:
672 raise
ValueError: in user code:
Since I am new to mask r-cnn, could you please help me to solve the problem?