Nkap23 / TensorFlow_with_Colab_tutorial

TensorFlow 2 Object Detection API with Google Colab!
MIT License
15 stars 23 forks source link

TypeError #2

Closed FunkyGandalf closed 3 years ago

FunkyGandalf commented 3 years ago

Hello, thanks for putting this together! I've been really struggling to find a reliable way to train a custom model and this looks like it's almost perfect for what I need.

I followed your instructions exactly and everything goes fine just until step 11. I get the following error. I did double check the folder locations are as required. Also, I made sure that the label map capitalization is the same as the XML files.

/content/gdrive/My Drive/TensorFlow/scripts/preprocessing Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/utils/label_map_util.py", line 171, in load_labelmap text_format.Merge(label_map_string, label_map) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 734, in Merge allow_unknown_field=allow_unknown_field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 802, in MergeLines return parser.MergeLines(lines, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 827, in MergeLines self._ParseOrMerge(lines, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 849, in _ParseOrMerge self._MergeField(tokenizer, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 974, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1048, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 974, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1099, in _MergeScalarField value = tokenizer.ConsumeString() File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1470, in ConsumeString the_bytes = self.ConsumeByteString() File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1485, in ConsumeByteString the_list = [self._ConsumeSingleByteString()] File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1504, in _ConsumeSingleByteString raise self.ParseError('Expected string but found: %r' % (text,)) google.protobuf.text_format.ParseError: 3:13 : ' name: ‘Bird’': Expected string but found: '‘'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "generate_tfrecord.py", line 59, in label_map = label_map_util.load_labelmap(args.labels_path) File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/utils/label_map_util.py", line 173, in load_labelmap label_map.ParseFromString(label_map_string) TypeError: a bytes-like object is required, not 'str' Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/utils/label_map_util.py", line 171, in load_labelmap text_format.Merge(label_map_string, label_map) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 734, in Merge allow_unknown_field=allow_unknown_field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 802, in MergeLines return parser.MergeLines(lines, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 827, in MergeLines self._ParseOrMerge(lines, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 849, in _ParseOrMerge self._MergeField(tokenizer, message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 974, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1048, in _MergeMessageField self._MergeField(tokenizer, sub_message) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 974, in _MergeField merger(tokenizer, message, field) File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1099, in _MergeScalarField value = tokenizer.ConsumeString() File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1470, in ConsumeString the_bytes = self.ConsumeByteString() File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1485, in ConsumeByteString the_list = [self._ConsumeSingleByteString()] File "/usr/local/lib/python3.6/dist-packages/google/protobuf/text_format.py", line 1504, in _ConsumeSingleByteString raise self.ParseError('Expected string but found: %r' % (text,)) google.protobuf.text_format.ParseError: 3:13 : ' name: ‘Bird’': Expected string but found: '‘'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "generate_tfrecord.py", line 59, in label_map = label_map_util.load_labelmap(args.labels_path) File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/utils/label_map_util.py", line 173, in load_labelmap label_map.ParseFromString(label_map_string) TypeError: a bytes-like object is required, not 'str'

Nkap23 commented 3 years ago

Hello, I think this is due to a quotation error in the label map file. Make sure that the quotations in your label map file are of the form '' (straight quotations) and not of the form ‘’ (curved quotation).

Thanks for raising this issue, I have updated the label map step in the article. Please change the label map file accordingly and retry again!

FunkyGandalf commented 3 years ago

Good catch! Yes, that error is resolved. Thank you!

On Tue, Oct 27, 2020 at 10:53 AM Nisarg Kapkar notifications@github.com wrote:

Hello, I think this is due to a quotation error in the label map file. Make sure that the quotations in your label map file are of the form '' (straight quotations) and not of the form ‘’ (curved quotation).

Thanks for raising this issue, I have updated the label map step in the article. Please change the label map file accordingly and retry again!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nkap23/TensorFlow_with_Colab_tutorial/issues/2#issuecomment-717299758, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQN4HWZMDMMEZT5BCPAFDOLSM3NGRANCNFSM4TA3OIAA .