import tensorflow as tf
imagePath = '/home/sk/test_set'
image_list = tf.gfile.ListDirectory(imagePath)
for i in image_list:
image_data = tf.gfile.FastGFile(i, 'rb').read()
当执行此代码错误时
Traceback (most recent call last):
File "/home/sk/tensorflow-classify/photos/as.py", line 18, in <module>
image_data = tf.gfile.FastGFile(i, 'rb').read()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 115, in read
self._preread_check()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 75, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/usr/local/lib/python2.7/dist-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.NotFoundError: 11.jpg
我认为tf.gfile.FastGFile(i,&#39; rb&#39;)。read()这不正常工作。 它在文件名是1.jpg时有效,但在发生错误后更改文件名
我该如何解决这个问题
答案 0 :(得分:1)
看起来路径imagePath = '/home/sk/test_set'
不正确或方法接受亲戚路线。
查看示例here 有一个FLAGS变量,用于定义所有路径,根据您的文件结构跟随leed,以及您在哪里有proyect