Windows 10上的Tensorflow对象检测Api错误model_main.py

时间:2018-08-23 17:50:23

标签: python tensorflow object-detection object-detection-api

我遵循EdjeElectronics' guide的有关如何使用Tensorflow-gpu 1.10和Python 3.6.6设置和运行TensorFlow对象检测API的信息。

使用以下命令运行model_main.py时:

  

python model_main.py --logtostderr --model_dir =培训/   --pipeline_config_path = C:/tensorflow1/models/research/object_detection/training/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config

我收到以下错误:

(tensorflow1) C:\tensorflow1\models\research\object_detection>python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=C:/tensorflow1/models/research/object_detection/training/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config
WARNING:tensorflow:Estimator's model_fn (<function create_model_fn.<locals>.model_fn at 0x00000213FF9CE158>) includes params argument, but params are not passed to Estimator.
Traceback (most recent call last):
  File "model_main.py", line 101, in <module>
    tf.app.run()
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File "model_main.py", line 97, in main
    tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 451, in train_and_evaluate
    return executor.run()
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 590, in run
    return self.run_local()
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 691, in run_local
    saving_listeners=saving_listeners)
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 376, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1145, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1167, in _train_model_default
    input_fn, model_fn_lib.ModeKeys.TRAIN))
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1011, in _get_features_and_labels_from_input_fn
    result = self._call_input_fn(input_fn, mode)
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1100, in _call_input_fn
    return input_fn(**kwargs)
  File "C:\tensorflow1\models\research\object_detection\inputs.py", line 408, in _train_input_fn
    batch_size=params['batch_size'] if params else train_config.batch_size)
  File "C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py", line 123, in build
    num_additional_channels=input_reader_config.num_additional_channels)
  File "C:\tensorflow1\models\research\object_detection\data_decoders\tf_example_decoder.py", line 271, in __init__
    use_display_name)
  File "C:\tensorflow1\models\research\object_detection\utils\label_map_util.py", line 163, in get_label_map_dict
    label_map = load_labelmap(label_map_path)
  File "C:\tensorflow1\models\research\object_detection\utils\label_map_util.py", line 132, in load_labelmap
    label_map_string = fid.read()
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read
    self._preread_check()
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 85, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 519, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: C:/tensorflow1/models/research/object_detection/training/mscoco_label_map.pbtxt : Das System kann die angegebene Datei nicht finden.
; No such file or directory

我检查了.config中的路径至少一百次, mscoco_label_map.pbtxt 确实存在于此目录中。任何想法可能有什么问题吗?

2 个答案:

答案 0 :(得分:0)

问题主要出在pbtxt文件夹路径格式上。如果您使用的是Windows,请按以下步骤在配置文件中尝试使用反斜杠。

所以不是- C:/tensorflow1/models/research/object_detection/training/mscoco_label_map.pbtxt

使用- C:\ tensorflow1 \ models \ research \ object_detection \ training \ mscoco_label_map.pbtxt

答案 1 :(得分:0)

我通过简单地重新创建.pbtxt解决了它。我仍然不知道问题到底出在哪里,但是现在它像一个魔术一样起作用。