我正在尝试将Tensorflow用于Windows 10和Anaconda Prompt的Poets 2。但是,运行此代码时,我在训练图像时遇到了麻烦:
python scripts/retrain.py
--bottleneck_dir=/tf_files/bottlenecks
--how_many_training_steps 500
--model_dir=/{$your-working_directory}/inception
--output_graph=/{$your-working_directory}/retrained_graph.pb
--output_labels=/{$your-working_directory}/retrained_labels.txt
--image_dir /tf_files/paintings
我有两个文件夹,两个文件夹都包含.jpg格式的图像。这两个文件夹位于“绘画”文件夹中。
即使我指定了图像目录,我仍然会收到此错误:
2018-09-04 19:40:46.876487: W
T:\src\github\tensorflow\tensorflow\core\framework\op_def_util.cc:346] Op
BatchNormWithGlobalNormalization is deprecated. It will cease to work in
GraphDef version 9. Use tf.nn.batch_normalization().
ERROR:tensorflow:Image directory '' not found.
Traceback (most recent call last):
File "C:\Users\JOHN\Anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _
run_module_as_main
"__main__", mod_spec)
File "C:\Users\JOHN\Anaconda3\envs\tensorflow\lib\runpy.py", line 85, in
_run_code
exec(code, run_globals)
File "C:\Users\JOHN\tensorflow-for-poets-2\scripts\retrain.py", line 1326,
in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "C:\Users\JOHN\Anaconda3\envs\tensorflow\lib\site-
packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "C:\Users\JOHN\tensorflow-for-poets-2\scripts\retrain.py", line 989, in
main
class_count = len(image_lists.keys())
AttributeError: 'NoneType' object has no attribute 'keys'
我已经检查了有关此问题的类似帖子,但对我而言没有用。
我该怎么办?
答案 0 :(得分:2)
/tf_files
意味着tf_files
文件夹在您的主目录下(这就是/
的含义),
您应该从目录参数中删除所有前导斜杠/
,即
python scripts/retrain.py
--bottleneck_dir=tf_files/bottlenecks
--how_many_training_steps=500
--model_dir={$your-working_directory}/inception
--output_graph={$your-working_directory}/retrained_graph.pb
--output_labels={$your-working_directory}/retrained_labels.txt
--image_dir=tf_files/paintings
当然假设已经定义了外壳变量your-working_directory
(如果没有定义,请用实际的工作目录替换它)。