我正在使用tensorflow 1.9进行自定义对象检测,并遵循与https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#preparing-workspace中相同的步骤。
但是在训练模型时,我遇到了错误。
(tensorflow_cpu) C:\Users\Z004032A\Documents\Tensorflow\workspace\training_demo>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_inception_v2_coco.config
WARNING:tensorflow:From C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\platform\app.py:125: main (from __main__) is deprecated and will be removed in a future version.
Instructions for updating:
Use object_detection/model_main.py.
Traceback (most recent call last):
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 1460, in _ConsumeSingleByteString
result = text_encoding.CUnescape(text[1:-1])
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_encoding.py", line 115, in CUnescape
.decode('unicode_escape')
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
在处理上述异常期间,发生了另一个异常:
Traceback (most recent call last):
File "train.py", line 184, in <module>
tf.app.run()
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\util\deprecation.py", line 250, in new_func
return func(*args, **kwargs)
File "train.py", line 93, in main
FLAGS.pipeline_config_path)
File "C:\Users\Z004032A\Documents\Tensorflow\models\research\object_detection\utils\config_util.py", line 100, in get_configs_from_pipeline_file
text_format.Merge(proto_str, pipeline_config)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 685, in Merge
allow_unknown_field=allow_unknown_field)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 752, in MergeLines
return parser.MergeLines(lines, message)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 777, in MergeLines
self._ParseOrMerge(lines, message)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 799, in _ParseOrMerge
self._MergeField(tokenizer, message)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 924, in _MergeField
merger(tokenizer, message, field)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 998, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 924, in _MergeField
merger(tokenizer, message, field)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 998, in _MergeMessageField
self._MergeField(tokenizer, sub_message)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 924, in _MergeField
merger(tokenizer, message, field)
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 1049, in _MergeScalarField
value = tokenizer.ConsumeString()
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 1420, in ConsumeString
the_bytes = self.ConsumeByteString()
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 1435, in ConsumeByteString
the_list = [self._ConsumeSingleByteString()]
File "C:\Users\Z004032A\anaconda3\envs\tensorflow_cpu\lib\site-packages\google\protobuf\text_format.py", line 1462, in _ConsumeSingleByteString
raise self.ParseError(str(e))
google.protobuf.text_format.ParseError: 170:17 : ' input_path: "C:\Users\Z004032A\Documents\Tensorflow\workspace\trai': 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
任何人都可以帮助我如何解决该问题,并告诉我哪个tensorflow版本最适合自定义对象检测
答案 0 :(得分:0)
这可能是Windows使用C:\作为默认用户目录引起的。当您以字符串形式在Python中使用此用户目录时,可能会出现unicode错误,因为使用了\ U unicode转义。
尝试复制反斜杠。换句话说,将C:\User\Documents
变成C:\\User\\Documents
。
关于哪种Tensorflow最佳版本,没有“最佳”版本。我建议使用与您正在使用的任何库相同的TF版本。我也建议不要在原始TF中编码。而是使用现有的库,例如YOLO。只需Google“最佳对象检测库tensorflow”,然后选择现有库之一。