qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.76k stars 1.03k forks source link

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

Open AidaSilva opened 3 years ago

AidaSilva commented 3 years ago

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.
JordanMakesMaps commented 3 years ago

This isn't a repo for MaskRCNN.

AidaSilva commented 3 years ago

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

AidaSilva commented 3 years ago

Hi Jordan Pierce,

I am using MaskRCNN repo from Matterpoart on github, this is the error I got from running the demo.

I would appreciate if you have some suggestions on how to go about it.

Thanks, Aida

On Tue, Jun 22, 2021 at 4:57 PM Jordan Pierce @.***> wrote:

This isn't a repo for MaskRCNN.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qubvel/segmentation_models/issues/481#issuecomment-866328093, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATJZQJ4BNSLGF7AKXUHSVJLTUD2LNANCNFSM47ATBWLA .

--

Aida da Silva

Student at WVU Major Civil Engineering @.***

JordanMakesMaps commented 3 years ago

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?

AidaSilva commented 3 years ago

Hi Jordan,

Thank you for writing back to me.

I am using the newest version of tf and Keras. I am able to run the demo. But I am having some issues with configuration as I am trying to train my own data set. I was wondering if you could help me. Here is the error message:

TypeError Traceback (most recent call last) in 25 config = CustomConfig() 26 model = modellib.MaskRCNN(mode="training", config=config,---> 27 model_dir=DEFAULT_LOGS_DIR) 28 29 weights_path = COCO_WEIGHTS_PATH ~\Mask_RCNN_foun\mrcnn\model.py in init(self, mode, config, model_dir) 1868 self.model_dir = model_dir 1869 self.set_log_dir()-> 1870 self.keras_model = self.build(mode=mode, config=config) 1871 1872 def build(self, mode, config): ~\Mask_RCNN_foun\mrcnn\model.py in build(self, mode, config) 1907

Normalize coordinates 1908 gt_boxes =

KL.Lambda(lambda x: norm_boxes_graph(-> 1909 x, K.shape(input_image)[1:3]))(input_gt_boxes) 1910 # 3. GT Masks (zero padded) 1911 # [batch, height, width, MAX_GT_INSTANCES] 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) 860 build_graph=False) 861 outputs = tf.nest.map_structure(--> 862 keras_tensor.keras_tensor_from_tensor, outputs) 863 864 if hasattr(self, '_set_inputs') and not self.inputs: c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\util\nest.py in map_structure(func, *structure, *kwargs) 865 866 return pack_sequence_as(--> 867 structure[0], [func(x) for x in entries], 868 expand_composites=expand_composites) 869 c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\util\nest.py in (.0) 865 866 return pack_sequence_as(--> 867 structure[0], [func(*x) for x in entries], 868 expand_composites=expand_composites) 869 c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\keras_tensor.py in keras_tensor_from_tensor(tensor) 578 break 579 --> 580 out = keras_tensor_cls.from_tensor(tensor) 581 582 if hasattr(tensor, '_keras_mask'): c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\keras\engine\keras_tensor.py in from_tensor(cls, tensor) 170 # Fallback to the generic arbitrary-typespec KerasTensor 171 name = getattr(tensor, 'name', None)--> 172 type_spec = tf.type_spec_from_value(tensor) 173 return cls(type_spec, name=name) 174 c:\users\owner\anaconda3\envs\maskrcnn\lib\site-packages\tensorflow\python\framework\type_spec.py in type_spec_from_value(value) 579 580 raise TypeError("Could not build a TypeSpec for %r with type %s" %--> 581 (value, type(value).name)) 582 583 TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) dtype=float32 (created by layer 'tf.math.truediv')> with type KerasTensor

On Wed, Jun 23, 2021 at 10:16 AM Jordan Pierce @.***> wrote:

Hi @AidaSilva https://github.com/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 https://github.com/matterport/Mask_RCNN/blob/master/requirements.txt?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qubvel/segmentation_models/issues/481#issuecomment-866875141, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATJZQJ7Q264KYQD4UVKE52TTUHUFFANCNFSM47ATBWLA .

--

Aida da Silva

Student at WVU Major Civil Engineering @.***

Moobbot2 commented 1 year ago

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?