I was using a custom code recognizing objects in real time using the webcam, but during the process of creating the labels this error appeared, I'm using python 3.7 and TensorFlow 1.15, which is wrong and there is an easier way to use real-time object recognition?
label map:
labels = [
{'name':'1DIG', 'id':1},
{'name':'2DIG', 'id':2},
{'name':'3DIG', 'id':3},
{'name':'4DIG', 'id':4},
]
with open(ANNOTATION_PATH + '\label_map.pbtxt', 'w') as f:
for label in labels:
f.write('item { \n')
f.write('\tname:\'{}\'\n'.format(label['name']))
f.write('\tid:{}\n'.format(label['id']))
f.write('}\n')
code to tf record:
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'}
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x{IMAGE_PATH + '/test'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/test.record'}
error:
Traceback (most recent call last):
File "Tensorflow/scripts/generate_tfrecord.py", line 62, in <module>
label_map_dict = label_map_util.get_label_map_dict(label_map)
File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python37\lib\site-packages\object_detection\utils\label_map_util.py", line 164, in get_label_map_dict
label_map = load_labelmap(label_map_path)
File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python37\lib\site-packages\object_detection\utils\label_map_util.py", line 133, in load_labelmap
label_map_string = fid.read()
File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\lib\io\file_io.py", line 122, in read
self._preread_check()
File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\lib\io\file_io.py", line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
File "C:\Users\Gabriel\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\util\compat.py", line 71, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got item {
name: "1DIG"
id: 1
}
item {
name: "2DIG"
id: 2
}
item {
name: "3DIG"
id: 3
}
item {
name: "4DIG"
id: 4
}
