models icon indicating copy to clipboard operation
models copied to clipboard

InvalidArgumentError: tfrecord data type mismatch when training mask rcnn on PET dataset

Open deercoder opened this issue 8 years ago • 3 comments

System information

  • What is the top-level directory of the model you are using: models/research
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): NO
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): CentOS Linux release 7.3.1611 (Core)
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.8
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version: cuda 8.0
  • GPU model and memory: K80, 12GB
  • Exact command to reproduce:
PIPELINE_CONFIG_PATH=object_detection/samples/configs/mask_rcnn_resnet101_pets.config
MODEL_DIR=object_detection/data/mask_rcnn_resnet101_atrous_coco_2018_01_28
NUM_TRAIN_STEPS=150000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1
python object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \
    --alsologtostderr

Describe the problem

When I train the Pets dataset for mask-rcnn using pretrained mask-rcnn model from coco dataset, I find that the object_detection/samples/configs/mask_rcnn_resnet101_pets.config has a problem that will make the training failed, the previous solution is in e45234, which adds the mask_type: PNG_MASKS in the config file, however, the newly code in master branch doesn't have such field that will cause the type mismatch, detailed log is as follows.

Addtionally, I find that in the config file the tfrecord is named input_path: "PATH_TO_BE_CONFIGURED/pet_fullbody_with_masks_train.record-?????-of-00010", however in its code /object_detection/dataset_tools/create_pet_tf_record.py, the file name is named pets_fullbody_with_masks_train, the minor difference between pet and pets will make the training interrupted with strange dimension mismatch error. I changed the config file to pets that will solve part of it.

After I added the changes in that previous commit, the problem disappear, I think the community should update the sample config file to avoid potential problems for beginners.

Source code / logs

WARNING:tensorflow:From /data1/cliu/g-models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py:1930: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and w
ill be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From /data1/cliu/g-models/research/object_detection/meta_architectures/faster_rcnn_meta_arch.py:1930: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and w
ill be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
/usr/lib/python2.7/site-packages/tensorflow/python/ops/gradients_impl.py:100: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
2018-10-22 16:54:25.805897: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties:
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:8b:00.0
totalMemory: 11.92GiB freeMemory: 11.44GiB
2018-10-22 16:54:25.805998: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2018-10-22 16:54:26.189911: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-10-22 16:54:26.190004: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0
2018-10-22 16:54:26.190030: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N
2018-10-22 16:54:26.190513: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 11093 MB memory) -> physical GPU (device: 0, name:
 Tesla K80, pci bus id: 0000:8b:00.0, compute capability: 3.7)
2018-10-22 16:55:06.921525: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.921501: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.921514: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.922122: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.922103: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.922092: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.922206: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.923368: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.923381: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
2018-10-22 16:55:06.924358: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/mask.  Data types don't match. Expected type: floa
t, Actual type: string
Traceback (most recent call last):
  File "object_detection/model_main.py", line 101, in <module>
    tf.app.run()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "object_detection/model_main.py", line 97, in main
    tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 439, in train_and_evaluate
    executor.run()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 518, in run
    self.run_local()
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/training.py", line 650, in run_local
    hooks=train_hooks)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 363, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 843, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 859, in _train_model_default
    saving_listeners)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 1059, in _train_with_estimator_spec
    _, loss = mon_sess.run([estimator_spec.train_op, estimator_spec.loss])
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 567, in run
    run_metadata=run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 1043, in run
    run_metadata=run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 1134, in run
    raise six.reraise(*original_exc_info)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 1119, in run
    return self._sess.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 1191, in run
    run_metadata=run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/training/monitored_session.py", line 971, in run
    return self._sess.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 900, in run
    run_metadata_ptr)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1135, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run
    run_metadata)
  File "/usr/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Key: image/object/mask.  Data types don't match. Expected type: float, Actual type: string
         [[Node: ParseSingleExample/ParseSingleExample = ParseSingleExample[Tdense=[DT_STRING, DT_STRING, DT_STRING, DT_INT64, DT_STRING, DT_STRING, DT_INT64], dense_keys=["image/encoded", "image/filename", "imag
e/format", "image/height", "image/key/sha256", "image/source_id", "image/width"], dense_shapes=[[], [], [], [], [], [], []], num_sparse=14, sparse_keys=["image/class/label", "image/class/text", "image/object/area
", "image/object/bbox/xmax", "image/object/bbox/xmin", "image/object/bbox/ymax", "image/object/bbox/ymin", "image/object/class/label", "image/object/class/text", "image/object/difficult", "image/object/group_of",
 "image/object/is_crowd", "image/object/mask", "image/object/weight"], sparse_types=[DT_INT64, DT_STRING, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_STRING, DT_INT64, DT_INT64, DT_INT64, DT_FL
OAT, DT_FLOAT]](Reshape, ParseSingleExample/Reshape, ParseSingleExample/Reshape_1, ParseSingleExample/Reshape_2, ParseSingleExample/Reshape_3, ParseSingleExample/Reshape_4, ParseSingleExample/Reshape_5, ParseSing
leExample/Reshape_6)]]
         [[Node: IteratorGetNext = IteratorGetNext[output_shapes=[[1], [1,?,?,3], [1,3], [1,100], [1,100,4], [1,100,37], [1,100], [1,100,?,?], [1,100], [1,100], [1]], output_types=[DT_INT32, DT_FLOAT, DT_INT32, D
T_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32, DT_FLOAT, DT_BOOL, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"](Iterator)]]
         [[Node: IteratorGetNext/_4831 = _HostRecv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_inca
rnation=1, tensor_name="edge_52_IteratorGetNext", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

deercoder avatar Oct 22 '18 21:10 deercoder

I've encountered the same problem and I could still use this fix [e45234] (https://github.com/tensorflow/models/commit/e45234e32dbc485f74567f6c0297edc9c084677c). The field mask_type is still supported because in the proto file it is still valid.

danyfang avatar Apr 26 '19 18:04 danyfang

Hi There, We are checking to see if you still need help on this, as this seems to be considerably old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

tensorflowbutler avatar Jan 29 '20 22:01 tensorflowbutler

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

amahendrakar avatar Feb 12 '20 04:02 amahendrakar