不确定为什么我的buildforimage_data.py脚本不能正常工作

时间:2017-04-16 20:42:52

标签: python image-processing tensorflow conv-neural-network tf-slim

我正在尝试将一组jpg图像转换为TFRecord,以便与Tensorflow中的CNN一起使用。我从这里使用脚本build_image_data.py:

https://github.com/tensorflow/models/blob/master/inception/inception/data/build_image_data.py

我已经创建了一个验证目录和一个培训目录以及带有相应标签的labels.txt文件。我使用jupyter notebook运行脚本(我也尝试过命令行),我已将tf.app.flags.DEFINE_string参数更改为相应的目录/文件名。当我运行它时,我收到以下错误:

[x+y | x <- list1, y <- list2, x != y]

任何线索?我正在从包含我的验证和培训文件夹的同一目录运行脚本。谢谢。

编辑:尝试使用完整路径但仍然出现相同的错误。这是代码的相关部分,我确信这是我的一些简单错误。

Saving results to /tmp/
Determining list of input files and labels from /tmp/.
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
<ipython-input-2-6349ff3421a2> in <module>()
    356 
    357 if __name__ == '__main__':
--> 358   tf.app.run()

C:\Users\Lenovo\Anaconda3\envs\tensorflow3_5\lib\site-packages\tensorflow\python\platform\app.py in run(main, argv)
     42   # Call the main function, passing through any arguments
     43   # to the final program.
---> 44   _sys.exit(main(_sys.argv[:1] + flags_passthrough))
     45 
     46 

<ipython-input-2-6349ff3421a2> in main(unused_argv)
    350   # Run it!
    351   _process_dataset('validation', FLAGS.validation_directory,
--> 352                    FLAGS.validation_shards, FLAGS.labels_file)
    353   _process_dataset('train', FLAGS.train_directory,
    354                    FLAGS.train_shards, FLAGS.labels_file)

<ipython-input-2-6349ff3421a2> in _process_dataset(name, directory, num_shards, labels_file)
    336     labels_file: string, path to the labels file.
    337   """
--> 338   filenames, texts, labels = _find_image_files(directory, labels_file)
    339   _process_image_files(name, filenames, texts, labels, num_shards)
    340 

<ipython-input-2-6349ff3421a2> in _find_image_files(data_dir, labels_file)
    288   print('Determining list of input files and labels from %s.' % data_dir)
    289   unique_labels = [l.strip() for l in tf.gfile.FastGFile(
--> 290       labels_file, 'r').readlines()]
    291 
    292   labels = []

C:\Users\Lenovo\Anaconda3\envs\tensorflow3_5\lib\site-packages\tensorflow\python\lib\io\file_io.py in readlines(self)
    126   def readlines(self):
    127     """Returns all lines from the file in a list."""
--> 128     self._preread_check()
    129     lines = []
    130     while True:

C:\Users\Lenovo\Anaconda3\envs\tensorflow3_5\lib\site-packages\tensorflow\python\lib\io\file_io.py in _preread_check(self)
     71       with errors.raise_exception_on_not_ok_status() as status:
     72         self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
---> 73             compat.as_bytes(self.__name), 1024 * 512, status)
     74 
     75   def _prewrite_check(self):

C:\Users\Lenovo\Anaconda3\envs\tensorflow3_5\lib\contextlib.py in __exit__(self, type, value, traceback)
     64         if type is None:
     65             try:
---> 66                 next(self.gen)
     67             except StopIteration:
     68                 return

C:\Users\Lenovo\Anaconda3\envs\tensorflow3_5\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status()
    464           None, None,
    465           compat.as_text(pywrap_tensorflow.TF_Message(status)),
--> 466           pywrap_tensorflow.TF_GetCode(status))
    467   finally:
    468     pywrap_tensorflow.TF_DeleteStatus(status)

NotFoundError: NewRandomAccessFile failed to Create/Open:  : The system cannot find the path specified. 

1 个答案:

答案 0 :(得分:0)

您应该将地址放在/ temp /

的位置
tf.app.flags.DEFINE_string('train_directory', 'D:/full/path',
                       'Training data directory')