tensorflow / tensorflow/models

Label_Map: a bytes-like object is required, not 'str'

Open
#8,582 1 comment 0 reactions 3 assignees View on GitHub

@pkulzc is already working on this.

Since May 28, 2020.

models:research:odapi type:support
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am a beginner so please help me out with this.
I am running this command to train a mask model but it gives me error no matter whatever I changed.
Here are some details:

  • custom code: Nope

  • Command: python model_main.py --logtostderr --model_dir=/home/mousam/Downloads/Dogs/model/ --pipeline_config_path=/home/mousam/.keras/datasets/mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/pipeline.config

  • error/log: /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint8 = np.dtype([("qint8", np.int8, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint16 = np.dtype([("qint16", np.int16, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint32 = np.dtype([("qint32", np.int32, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    np_resource = np.dtype([("resource", np.ubyte, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint8 = np.dtype([("qint8", np.int8, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint16 = np.dtype([("qint16", np.int16, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    _np_qint32 = np.dtype([("qint32", np.int32, 1)])
    /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
    np_resource = np.dtype([("resource", np.ubyte, 1)])
    WARNING:tensorflow:
    The TensorFlow contrib module will not be included in TensorFlow 2.0.
    For more information, please see:

WARNING:tensorflow:From model_main.py:109: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/config_util.py:102: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

W0527 17:36:23.862397 140306570090304 deprecation_wrapper.py:119] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/config_util.py:102: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/model_lib.py:628: The name tf.logging.warning is deprecated. Please use tf.compat.v1.logging.warning instead.

W0527 17:36:23.866144 140306570090304 deprecation_wrapper.py:119] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/model_lib.py:628: The name tf.logging.warning is deprecated. Please use tf.compat.v1.logging.warning instead.

WARNING:tensorflow:Forced number of epochs for all eval validations to be 1.
W0527 17:36:23.866272 140306570090304 model_lib.py:629] Forced number of epochs for all eval validations to be 1.
WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/config_util.py:488: The name tf.logging.info is deprecated. Please use tf.compat.v1.logging.info instead.

W0527 17:36:23.866388 140306570090304 deprecation_wrapper.py:119] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/config_util.py:488: The name tf.logging.info is deprecated. Please use tf.compat.v1.logging.info instead.

INFO:tensorflow:Maybe overwriting train_steps: None
I0527 17:36:23.866481 140306570090304 config_util.py:488] Maybe overwriting train_steps: None
INFO:tensorflow:Maybe overwriting use_bfloat16: False
I0527 17:36:23.866568 140306570090304 config_util.py:488] Maybe overwriting use_bfloat16: False
INFO:tensorflow:Maybe overwriting sample_1_of_n_eval_examples: 1
I0527 17:36:23.866660 140306570090304 config_util.py:488] Maybe overwriting sample_1_of_n_eval_examples: 1
INFO:tensorflow:Maybe overwriting eval_num_epochs: 1
I0527 17:36:23.866752 140306570090304 config_util.py:488] Maybe overwriting eval_num_epochs: 1
INFO:tensorflow:Maybe overwriting load_pretrained: True
I0527 17:36:23.866844 140306570090304 config_util.py:488] Maybe overwriting load_pretrained: True
INFO:tensorflow:Ignoring config override key: load_pretrained
I0527 17:36:23.866931 140306570090304 config_util.py:498] Ignoring config override key: load_pretrained
WARNING:tensorflow:Expected number of evaluation epochs is 1, but instead encountered eval_on_train_input_config.num_epochs = 0. Overwriting num_epochs to 1.
W0527 17:36:23.867132 140306570090304 model_lib.py:645] Expected number of evaluation epochs is 1, but instead encountered eval_on_train_input_config.num_epochs = 0. Overwriting num_epochs to 1.
INFO:tensorflow:create_estimator_and_inputs: use_tpu False, export_to_tpu False
I0527 17:36:23.867237 140306570090304 model_lib.py:680] create_estimator_and_inputs: use_tpu False, export_to_tpu False
INFO:tensorflow:Using config: {'_model_dir': '/home/mousam/Downloads/Dogs/model/', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
rewrite_options {
meta_optimizer_iterations: ONE
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f9b41642850>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
I0527 17:36:23.867632 140306570090304 estimator.py:209] Using config: {'_model_dir': '/home/mousam/Downloads/Dogs/model/', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': allow_soft_placement: true
graph_options {
rewrite_options {
meta_optimizer_iterations: ONE
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f9b41642850>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
WARNING:tensorflow:Estimator's model_fn (<function create_model_fn..model_fn at 0x7f9b41640b90>) includes params argument, but params are not passed to Estimator.
W0527 17:36:23.867816 140306570090304 model_fn.py:630] Estimator's model_fn (<function create_model_fn..model_fn at 0x7f9b41640b90>) includes params argument, but params are not passed to Estimator.
INFO:tensorflow:Not using Distribute Coordinator.
I0527 17:36:23.868153 140306570090304 estimator_training.py:186] Not using Distribute Coordinator.
INFO:tensorflow:Running training and evaluation locally (non-distributed).
I0527 17:36:23.868317 140306570090304 training.py:612] Running training and evaluation locally (non-distributed).
INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps None or save_checkpoints_secs 600.
I0527 17:36:23.868552 140306570090304 training.py:700] Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps None or save_checkpoints_secs 600.
WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/training/training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
W0527 17:36:23.873242 140306570090304 deprecation.py:323] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/training/training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py:182: The name tf.FixedLenFeature is deprecated. Please use tf.io.FixedLenFeature instead.

W0527 17:36:23.883456 140306570090304 deprecation_wrapper.py:119] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py:182: The name tf.FixedLenFeature is deprecated. Please use tf.io.FixedLenFeature instead.

WARNING:tensorflow:From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py:197: The name tf.VarLenFeature is deprecated. Please use tf.io.VarLenFeature instead.

W0527 17:36:23.883702 140306570090304 deprecation_wrapper.py:119] From /home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py:197: The name tf.VarLenFeature is deprecated. Please use tf.io.VarLenFeature instead.

Traceback (most recent call last):
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/label_map_util.py", line 142, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 702, in Merge
allow_unknown_field=allow_unknown_field)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 770, in MergeLines
return parser.MergeLines(lines, message)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 795, in MergeLines
self._ParseOrMerge(lines, message)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 817, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 885, in _MergeField
name = tokenizer.ConsumeIdentifierOrNumber()
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/google/protobuf/text_format.py", line 1353, in ConsumeIdentifierOrNumber
raise self.ParseError('Expected identifier or number, got %s.' % result)
google.protobuf.text_format.ParseError: 1:1 : ''item {': Expected identifier or number, got 'item {.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "model_main.py", line 109, in
tf.app.run()
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "model_main.py", line 105, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate
return executor.run()
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run
return self.run_local()
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local
saving_listeners=saving_listeners)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 367, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1158, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1185, in _train_model_default
input_fn, ModeKeys.TRAIN))
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1022, in _get_features_and_labels_from_input_fn
self._call_input_fn(input_fn, mode))
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1113, in _call_input_fn
return input_fn(**kwargs)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/inputs.py", line 504, in _train_input_fn
params=params)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/inputs.py", line 607, in train_input
batch_size=params['batch_size'] if params else train_config.batch_size)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/builders/dataset_builder.py", line 130, in build
num_additional_channels=input_reader_config.num_additional_channels)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 319, in init
default_value=''),
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/data_decoders/tf_example_decoder.py", line 64, in init
label_map_proto_file, use_display_name=False)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/label_map_util.py", line 172, in get_label_map_dict
label_map = load_labelmap(label_map_path_or_proto)
File "/home/mousam/anaconda3/envs/tensorflow_train/lib/python3.7/site-packages/object_detection/utils/label_map_util.py", line 144, in load_labelmap
label_map.ParseFromString(label_map_string)
TypeError: a bytes-like object is required, not 'str'

  • additional: I used coco_to_tfrecord.py to create tfrecords which does not required any label_map.pbtxt and and labels are in the form of polygons.

Some Screenshots to help you out
directory
label_map
model_dir
pipeline
pipeline1
pipeline2
pipeline3
tf_record
tf_record1
tf_record2

Please Let me know if you want any other info

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.