Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

TypeError: Tensors in list passed to 'values' of 'Pack' Op have types [int32, int64] that don't all match.

Open yaoliu0803 opened this issue 2 years ago • 0 comments

use MaskRCNN in google colab:

position: model = modellib.MaskRCNN(mode="training", config=config,model_dir=MODEL_DIR)

mistake tip:

ValueError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(op_type_name, name, **keywords) 413 preferred_dtype=default_dtype, --> 414 as_ref=input_arg.is_ref) 415 if input_arg.number_attr and len(

12 frames /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in internal_convert_n_to_tensor(values, dtype, name, as_ref, preferred_dtype, ctx) 1566 preferred_dtype=preferred_dtype, -> 1567 ctx=ctx)) 1568 return ret

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types) 1474 "Tensor conversion requested dtype %s for Tensor with dtype %s: %r" % -> 1475 (dtype.name, value.dtype.name, value)) 1476 return value

ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: <tf.Tensor 'mrcnn_bbox_loss/Cast:0' shape=(?,) dtype=int64>

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) in 19 #4、创建Mask RCNN模型,模型保存到logs中。 Create model in training mode 20 print("MODEL_DIR=",MODEL_DIR) ---> 21 model = modellib.MaskRCNN(mode="training", config=config,model_dir=MODEL_DIR) 22 23

/usr/local/lib/python3.7/dist-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py in init(self, mode, config, model_dir) 1852 self.model_dir = model_dir 1853 self.set_log_dir() -> 1854 self.keras_model = self.build(mode=mode, config=config) 1855 1856 def build(self, mode, config):

/usr/local/lib/python3.7/dist-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py in build(self, mode, config) 2034 [target_class_ids, mrcnn_class_logits, active_class_ids]) 2035 bbox_loss = KL.Lambda(lambda x: mrcnn_bbox_loss_graph(*x), name="mrcnn_bbox_loss")( -> 2036 [target_bbox, target_class_ids, mrcnn_bbox]) 2037 mask_loss = KL.Lambda(lambda x: mrcnn_mask_loss_graph(*x), name="mrcnn_mask_loss")( 2038 [target_mask, target_class_ids, mrcnn_mask])

/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer_v1.py in call(self, *args, **kwargs) 774 try: 775 with ops.enable_auto_cast_variables(self._compute_dtype_object): --> 776 outputs = call_fn(cast_inputs, *args, **kwargs) 777 778 except errors.OperatorNotAllowedInGraphError as e:

/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/core.py in call(self, inputs, mask, training) 901 with backprop.GradientTape(watch_accessed_variables=True) as tape,
902 variable_scope.variable_creator_scope(_variable_creator): --> 903 result = self.function(inputs, **kwargs) 904 self._check_variables(created_variables, tape.watched_variables()) 905 return result

/usr/local/lib/python3.7/dist-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py in (x) 2033 class_loss = KL.Lambda(lambda x: mrcnn_class_loss_graph(*x), name="mrcnn_class_loss")( 2034 [target_class_ids, mrcnn_class_logits, active_class_ids]) -> 2035 bbox_loss = KL.Lambda(lambda x: mrcnn_bbox_loss_graph(*x), name="mrcnn_bbox_loss")( 2036 [target_bbox, target_class_ids, mrcnn_bbox]) 2037 mask_loss = KL.Lambda(lambda x: mrcnn_mask_loss_graph(*x), name="mrcnn_mask_loss")(

/usr/local/lib/python3.7/dist-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py in mrcnn_bbox_loss_graph(target_bbox, target_class_ids, pred_bbox) 1132 tf.gather(target_class_ids, positive_roi_ix), tf.int64) 1133 # indices = tf.stack([positive_roi_ix, positive_roi_class_ids], axis=1) -> 1134 indices = tf.stack([tf.range(tf.shape(positive_roi_ix)[0]), positive_roi_class_ids], axis=1) 1135 1136 # Gather the deltas (predicted and true) that contribute to loss

/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs) 199 """Call target, and fall back on dispatchers if there is a TypeError.""" 200 try: --> 201 return target(*args, **kwargs) 202 except (TypeError, ValueError): 203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/array_ops.py in stack(values, axis, name) 1387 (axis, -expanded_num_dims, expanded_num_dims)) 1388 -> 1389 return gen_array_ops.pack(values, axis=axis, name=name) 1390 1391

/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/gen_array_ops.py in pack(values, axis, name) 6475 axis = _execute.make_int(axis, "axis") 6476 _, _, _op, _outputs = _op_def_library._apply_op_helper( -> 6477 "Pack", values=values, axis=axis, name=name) 6478 _result = _outputs[:] 6479 if _execute.must_record_gradient():

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(op_type_name, name, **keywords) 440 (prefix, dtype.name)) 441 else: --> 442 raise TypeError("%s that don't all match." % prefix) 443 else: 444 raise TypeError(

TypeError: Tensors in list passed to 'values' of 'Pack' Op have types [int32, int64] that don't all match.

yaoliu0803 avatar Aug 30 '22 12:08 yaoliu0803