Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: expected bytes, str found #148

Open
AbdulQadir8 opened this issue Aug 8, 2023 · 3 comments
Open

TypeError: expected bytes, str found #148

AbdulQadir8 opened this issue Aug 8, 2023 · 3 comments

Comments

@AbdulQadir8
Copy link

When trying to execute: TF_RECORD_SCRIPT file
!python {files['TF_RECORD_SCRIPT']} -x {os.path.join(paths['IMAGE_PATH'], 'train')} -l {files['LABELMAP']} -o {os.path.join(paths['ANNOTATION_PATH'], 'train.record')}
!python {files['TF_RECORD_SCRIPT']} -x {os.path.join(paths['IMAGE_PATH'], 'test')} -l {files['LABELMAP']} -o {os.path.join(paths['ANNOTATION_PATH'], 'test.record')}
facing this issue. Can anyone guide me?

Traceback (most recent call last):
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/object_detection/utils/label_map_util.py", line 175, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 744, in Merge
return MergeLines(
^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 818, in MergeLines
return parser.MergeLines(lines, message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 843, in MergeLines
self._ParseOrMerge(lines, message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 867, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 1004, in _MergeField
merger(tokenizer, message, field)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 1085, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 965, in _MergeField
raise tokenizer.ParseErrorPreviousToken(
google.protobuf.text_format.ParseError: 3:1 : Message type "object_detection.protos.StringIntLabelMapItem" has no field named "tid".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/Tensorflow/scripts/generate_tfrecord.py", line 61, in
label_map = label_map_util.load_labelmap(args.labels_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/object_detection/utils/label_map_util.py", line 177, in load_labelmap
label_map.ParseFromString(label_map_string)
TypeError: expected bytes, str found
Traceback (most recent call last):
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/object_detection/utils/label_map_util.py", line 175, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 744, in Merge
return MergeLines(
^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 818, in MergeLines
return parser.MergeLines(lines, message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 843, in MergeLines
self._ParseOrMerge(lines, message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 867, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 1004, in _MergeField
merger(tokenizer, message, field)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 1085, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/google/protobuf/text_format.py", line 965, in _MergeField
raise tokenizer.ParseErrorPreviousToken(
google.protobuf.text_format.ParseError: 3:1 : Message type "object_detection.protos.StringIntLabelMapItem" has no field named "tid".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/Tensorflow/scripts/generate_tfrecord.py", line 61, in
label_map = label_map_util.load_labelmap(args.labels_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/abdul-qadir/Desktop/Computer/Tensorflow Object Detection/TFOD/tfod/lib/python3.11/site-packages/object_detection/utils/label_map_util.py", line 177, in load_labelmap
label_map.ParseFromString(label_map_string)
TypeError: expected bytes, str found

@TheShortKing69
Copy link

Traceback (most recent call last):
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\utils\label_map_util.py", line 175, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 719, in Merge
return MergeLines(
^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 793, in MergeLines
return parser.MergeLines(lines, message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 818, in MergeLines
self._ParseOrMerge(lines, message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 837, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 967, in _MergeField
merger(tokenizer, message, field)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 1042, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 932, in _MergeField
raise tokenizer.ParseErrorPreviousToken(
google.protobuf.text_format.ParseError: 2:17 : Message type "object_detection.protos.StringIntLabelMapItem" has no field named "n".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\Tensorflow\scripts\generate_tfrecord.py", line 61, in
label_map = label_map_util.load_labelmap(args.labels_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\utils\label_map_util.py", line 177, in load_labelmap
label_map.ParseFromString(label_map_string)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\message.py", line 202, in ParseFromString
return self.MergeFromString(serialized)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\internal\python_message.py", line 1125, in MergeFromString
serialized = memoryview(serialized)
^^^^^^^^^^^^^^^^^^^^^^
TypeError: memoryview: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\utils\label_map_util.py", line 175, in load_labelmap
text_format.Merge(label_map_string, label_map)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 719, in Merge
return MergeLines(
^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 793, in MergeLines
return parser.MergeLines(lines, message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 818, in MergeLines
self._ParseOrMerge(lines, message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 837, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 967, in _MergeField
merger(tokenizer, message, field)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 1042, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\text_format.py", line 932, in _MergeField
raise tokenizer.ParseErrorPreviousToken(
google.protobuf.text_format.ParseError: 2:17 : Message type "object_detection.protos.StringIntLabelMapItem" has no field named "n".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\Tensorflow\scripts\generate_tfrecord.py", line 61, in
label_map = label_map_util.load_labelmap(args.labels_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\utils\label_map_util.py", line 177, in load_labelmap
label_map.ParseFromString(label_map_string)
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\message.py", line 202, in ParseFromString
return self.MergeFromString(serialized)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HP\Documents\ML\TensorFlow Object Detection\TFODCourse\tfod\Lib\site-packages\google\protobuf\internal\python_message.py", line 1125, in MergeFromString
serialized = memoryview(serialized)
^^^^^^^^^^^^^^^^^^^^^^
TypeError: memoryview: a bytes-like object is required, not 'str'

@TheShortKing69
Copy link

Same Problem here :(

@sabbir2609
Copy link

What's the python version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants