【问题标题】:Running export_inference_graph.py throws an attribute error运行 export_inference_graph.py 会引发属性错误
【发布时间】:2018-06-08 18:15:17
【问题描述】:

所以,在云端训练后,我尝试使用以下链接导出推理图:

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/exporting_models.md

我使用的代码是:

python export_inference_graph.py \--input_type image_tensor \--pipeline_config_path samples/configs/ssd_mobilenet_v1_pets \--trained_checkpoint_prefix training\model.ckpt-29809 \--output_directory crop_graph1

它会抛出一个错误:

C:\Users\kannan\Desktop\Deep Learning 项目\GCP\models\research\object_detection>python export_inference_graph.py --input_type image_tensor --pipeline_config_path samples/configs/ssd_mobilenet_v1_pets --trained_checkpoint_prefix 训练\model.ckpt-29809 --output_directory crop_graph1 Traceback(最近一次调用最后一次):
文件“export_inference_graph.py”,第 119 行,在 tf.app.run() 文件 "C:\Users\kannan\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", 第 41 行,运行中 flags_passthrough = f._parse_flags(args=args) 文件 "C:\Users\kannan\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\flags.py", 第 45 行,在 _parse_flags 中 self._assert_all_required() 文件 "C:\Users\kannan\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\flags.py", 第 78 行,在 _assert_all_required self._assert_required(flag_name) 文件 "C:\Users\kannan\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\flags.py", 第 74 行,在 _assert_required 中 raise AttributeError('Flag --%s must be specified.' % flag_name) AttributeError: Flag --output_directory must be specified.

知道如何解决这个问题吗?

【问题讨论】:

    标签: python tensorflow google-cloud-platform google-cloud-ml


    【解决方案1】:

    我认为问题出在下面一行

    \--trained_checkpoint_prefix training\model.ckpt-29809 \--output_directory crop_graph1
    

    这个training\model.ckpt-29809 应该有一个像这样的双引号

    "training\model.ckpt-29809"
    

    我假设 python 正在处理 ckpt 和 29809 之间的额外“-” 或者可能删除反斜杠,因为它意味着连续命令。

    命令应该在一行中,不带“\”

    python export_inference_graph.py --input_type image_tensor --pipeline_config_path samples/configs/ssd_mobilenet_v1_pets --trained_checkpoint_prefix "training\model.ckpt-29809" --output_directory crop_graph1
    

    【讨论】:

    • 我确实尝试了你的建议,但仍然抛出同样的错误
    • 是的!那行得通。早些时候,在本地训练时,它使用“\”。为什么会这样?
    • "\" 如果您发出多行命令则很好,这意味着上一行尚未完成,后续行是前行的一部分
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多