【发布时间】:2018-05-01 14:31:12
【问题描述】:
我正在使用 python tensorflow 来训练模型以识别 python 中的图像。但是在尝试从github 执行 train.py 时出现以下错误
Traceback (most recent call last):
File "train.py", line 1023, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "C:\Users\sande\Anaconda3\envs\tensorflow\lib\site-
packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train.py", line 766, in main
bottleneck_tensor)
File "train.py", line 393, in cache_bottlenecks
jpeg_data_tensor, bottleneck_tensor)
File "train.py", line 341, in get_or_create_bottleneck
bottleneck_tensor)
File "train.py", line 290, in create_bottleneck_file
print('Creating bottleneck at ' + bottleneck_path)
OSError: raw write() returned invalid length 112 (should have been between 0
and 56)
下面是 create_bottleneck_file() 的代码
def create_bottleneck_file(bottleneck_path, image_lists, label_name, index,
image_dir, category, sess, jpeg_data_tensor,
bottleneck_tensor):
"""Create a single bottleneck file."""
print('Creating bottleneck at ' + bottleneck_path)
image_path = get_image_path(image_lists, label_name, index,
image_dir, category)
if not gfile.Exists(image_path):
tf.logging.fatal('File does not exist %s', image_path)
image_data = gfile.FastGFile(image_path, 'rb').read()
try:
bottleneck_values = run_bottleneck_on_image(
sess, image_data, jpeg_data_tensor, bottleneck_tensor)
except:
raise RuntimeError('Error during processing file %s' % image_path)
bottleneck_string = ','.join(str(x) for x in bottleneck_values)
with open(bottleneck_path, 'w') as bottleneck_file:
bottleneck_file.write(bottleneck_string)
我尝试减少文件名,以便bottleneck_path 将是一个小值,但没有奏效。我试图在网上搜索这个错误,但没有找到任何有用的东西。如果您有解决此问题的方法,请告诉我
【问题讨论】:
-
我认为问题在于您在 Windows 上运行该应用程序,但该代码适用于 Linux 或 Mac OS。如果在第 338 行运行
print(bottleneck_path),输出是什么? -
我认为你在 cmd 运行时与 cmd 进行了交互,也许这可以帮助stackoverflow.com/questions/48371993/…
标签: python python-3.x image-processing tensorflow