我正在尝试设置Tensorflow的Object Detection API并关注this doc
我正在训练我的模型时遇到以下错误(它抱怨找不到检查点文件,但它存在):
python object_detection/train.py --logtostderr --pipeline_config_path=/c/ObjectDetection/models/model/faster_rcnn_resnet101_voc07_2.config --train_dir=/c/ObjectDetection/models/model/train
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Scale of 0 disables regularizer.
INFO:tensorflow:Summary name Learning Rate is illegal; using Learning_Rate instead.
Traceback (most recent call last):
File "object_detection/train.py", line 198, in <module>
tf.app.run()
File "C:\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "object_detection/train.py", line 194, in main
worker_job_name, is_chief, FLAGS.train_dir)
File "C:\ObjectDetection\models\object_detection\trainer.py", line 218, in train
var_map, train_config.fine_tune_checkpoint))
File "C:\ObjectDetection\models\object_detection\utils\variables_helper.py", line 122, in get_variables_available_in_checkpoint
ckpt_reader = tf.train.NewCheckpointReader(checkpoint_path)
File "C:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 118, in NewCheckpointReader
return CheckpointReader(compat.as_bytes(filepattern), status)
File "C:\Python\Python35\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor: Failed to get matching files on /c/ObjectDetection/faster_rcnn_resnet101_coco_11_06_2017/model.ckpt: Not found: FindFirstFile failed for: /c/ObjectDetection/faster_rcnn_resnet101_coco_11_06_2017 : The system cannot find the path specified.
我尝试过Windows和Linux格式的检查点文件路径,我收到以下错误:
Windows格式路径('C:\ ObjectDetectionaster_rcnn_resnet101_coco_11_06_2017 \ model.ckpt')
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor:
Failed to get matching files on C:\ObjectDetection
aster_rcnn_resnet101_coco_11_06_2017\model.ckpt: Invalid argument:
FindFirstFile failed for: C:/ObjectDetection
aster_rcnn_resnet101_coco_11_06_2017 : The filename, directory name, or volume label syntax is incorrect.
Linux格式路径('/c/ObjectDetection/faster_rcnn_resnet101_coco_11_06_2017/model.ckpt')
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unsuccessful TensorSliceReader constructor:
Failed to get matching files on /c/ObjectDetection/faster_rcnn_resnet101_coco_11_06_2017/model.ckpt: Not found:
FindFirstFile failed for: /c/ObjectDetection/faster_rcnn_resnet101_coco_11_06_2017 : The system cannot find the path specified.
答案 0 :(得分:2)
正如您的错误消息所说,这是路径的问题,而不是TensorFlow功能的问题。
即使在Git Bash中,我也使用标准的Windows样式路径,即'C:\'而不是'/ c /'。此外,您需要转义\
或使其成为原始字符串。如:
'C:\\ObjectDetection\\faster_rcnn_resnet101_coco_11_06_2017\\model.ckpt'
# or
r'C:\ObjectDetection\\faster_rcnn_resnet101_coco_11_06_2017\\model.ckpt'
请注意,在您的粘贴路径中,它显示C:\ObjectDetectionaster_rcnn_...
而不是C:\ObjectDetection\faster_rcnn_...
。那是因为\f
引用了转义序列:
>>> print('\f')
>>> ord('\f')
12
>>> print('\\f') # escape the slash
\f
>>> print(r'\f') # or use raw strings with the 'r' prefix
\f