qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I am training MaskRCNN model and I run into this errorValueError: None values not supported

AidaSilva opened this issue · comments

WARNING:tensorflow:From c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\ops\array_ops.py:5049: calling gather (from tensorflow.python.ops.array_ops) with validate_indices is deprecated and will be removed in a future version.
Instructions for updating:
The validate_indices argument has no effect. Indices are always validated on CPU and never validated on GPU.

ValueError Traceback (most recent call last)
in
1 # Create model object in inference mode.
----> 2 model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)
3
4 # Load weights trained on MS-COCO
5 model.load_weights(COCO_MODEL_PATH, by_name=True)

~\Mask_RCNN\mrcnn\model.py in init(self, mode, config, model_dir)
1837 self.model_dir = model_dir
1838 self.set_log_dir()
-> 1839 self.keras_model = self.build(mode=mode, config=config)
1840
1841 def build(self, mode, config):

~\Mask_RCNN\mrcnn\model.py in build(self, mode, config)
2044 # normalized coordinates
2045 detections = DetectionLayer(config, name="mrcnn_detection")(
-> 2046 [rpn_rois, mrcnn_class, mrcnn_bbox, input_image_meta])
2047
2048 # Create masks for detections

c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\base_layer.py in call(self, *args, **kwargs)
944 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
945 return self._functional_construction_call(inputs, args, kwargs,
--> 946 input_list)
947
948 # Maintains info about the Layer.call stack.

c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1082 # Check input assumptions set after layer building, e.g. input shape.
1083 outputs = self._keras_tensor_symbolic_call(
-> 1084 inputs, input_masks, args, kwargs)
1085
1086 if outputs is None:

c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\base_layer.py in _keras_tensor_symbolic_call(self, inputs, input_masks, args, kwargs)
814 return tf.nest.map_structure(keras_tensor.KerasTensor, output_signature)
815 else:
--> 816 return self._infer_output_signature(inputs, args, kwargs, input_masks)
817
818 def _infer_output_signature(self, inputs, args, kwargs, input_masks):

c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\base_layer.py in _infer_output_signature(self, inputs, args, kwargs, input_masks)
854 self._maybe_build(inputs)
855 inputs = self._maybe_cast_inputs(inputs)
--> 856 outputs = call_fn(inputs, *args, **kwargs)
857
858 self._handle_activity_regularization(inputs, outputs)

c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\autograph\impl\api.py in wrapper(*args, **kwargs)
693 except Exception as e: # pylint:disable=broad-except
694 if hasattr(e, 'ag_error_metadata'):
--> 695 raise e.ag_error_metadata.to_exception(e)
696 else:
697 raise

ValueError: in user code:

C:\Users\Owner\Mask_RCNN\mrcnn\model.py:812 call  *
    detections_batch = utils.batch_slice(
C:\Users\Owner\Mask_RCNN\mrcnn\utils.py:820 batch_slice  *
    output_slice = graph_fn(*inputs_slice)
C:\Users\Owner\Mask_RCNN\mrcnn\model.py:704 refine_detections_graph  *
    indices = tf.stack([tf.range(probs.shape[0]), class_ids], axis=1)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\util\dispatch.py:206 wrapper  **
    return target(*args, **kwargs)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\ops\math_ops.py:1908 range
    limit = ops.convert_to_tensor(limit, dtype=dtype, name="limit")
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\profiler\trace.py:163 wrapped
    return func(*args, **kwargs)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\ops.py:1566 convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\constant_op.py:339 _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\constant_op.py:265 constant
    allow_broadcast=True)
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\constant_op.py:283 _constant_impl
    allow_broadcast=allow_broadcast))
c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\tensor_util.py:445 make_tensor_proto
    raise ValueError("None values not supported.")

ValueError: None values not supported.

This isn't a repo for MaskRCNN.

This is the demo from MaskRCNN and I keep getting the same error ValueError: None values not supported.

Hi @AidaSilva, yes I see that this is code for Matterport's MaskRCNN implementation in Keras, however this repository is qubvel's semantic segmentation repository. It might be more helpful for you to post your issues in Matterport's repo instead.

But since we're already here: looking at the error it seems that something is unutilized and is equal to None when it should be something else. I'd recommend checking your config and MODEL_DIR variables first. It's also possible that you're using different versions of Tensorflow, Keras, and other dependencies that Matterport's code relies on. Can you confirm you're using the correct requirements?

I user python 11
tf, keras 2.12
It's the same:
/content/drive/MyDrive/DoAn/Teeth/Mask-R-CNN-using-Tensorflow2-main/mrcnn/model.py in if_body()
40 nonlocal keep
41 conf_keep = ag__.converted_call(ag__.ld(tf).where, (ag__.ld(class_scores) >= ag__.ld(config).DETECTION_MIN_CONFIDENCE,), None, fscope)[:, 0]
---> 42 keep = ag__.converted_call(ag__.ld(tf).sparse.to_dense, (ag__.converted_call(ag__.ld(tf).expand_dims, (ag__.ld(keep), 0), None, fscope), ag__.converted_call(ag__.ld(tf).expand_dims, (ag__.ld(conf_keep), 0), None, fscope)), None, fscope)
43 keep = ag__.converted_call(ag__.ld(tf).sparse.to_dense, (ag__.ld(keep),), None, fscope)[0]
44

TypeError: Exception encountered when calling layer "mrcnn_detection" (type DetectionLayer).

in user code:

File "/content/drive/MyDrive/DoAn/Teeth/Mask-R-CNN-using-Tensorflow2-main/mrcnn/model.py", line 812, in call  *
    detections_batch = utils.batch_slice(
File "/content/drive/MyDrive/DoAn/Teeth/Mask-R-CNN-using-Tensorflow2-main/mrcnn/utils.py", line 820, in batch_slice  *
    output_slice = graph_fn(*inputs_slice)
File "/content/drive/MyDrive/DoAn/Teeth/Mask-R-CNN-using-Tensorflow2-main/mrcnn/model.py", line 721, in refine_detections_graph  *
    keep = tf.sparse.to_dense(tf.expand_dims(keep, 0),

TypeError: Input must be a SparseTensor.

Call arguments received by layer "mrcnn_detection" (type DetectionLayer):
• inputs=['tf.Tensor(shape=(1, None, 4), dtype=float32)', 'tf.Tensor(shape=(1, None, 3), dtype=float32)', 'tf.Tensor(shape=(1, None, 3, 4), dtype=float32)', 'tf.Tensor(shape=(None, 15), dtype=float32)']

Did you fix it yet?