tensorflowjs_converter:SavedModel文件在以下位置不存在:

时间:2018-11-19 00:38:45

标签: tensorflow tensorflowjs-converter

我正在按照here的说明将使用Python生成的Tensorflow模型导入Tensorflow.js。

使用tf.estimator API创建模型,该模型会根据this page自动保存模型文件。

使用pip安装tensorflowjs后,运行转换脚本时出现以下错误:

$ tensorflowjs_converter     --input_format=tf_saved_model     --output_node_names='DeepWater'     /home/sterengiannini/deepwater/model-js-import-test     /home/sterengiannini/deepwater/web-model
Using TensorFlow backend.
Traceback (most recent call last):
  File "/usr/local/bin/tensorflowjs_converter", line 11, in <module>
    sys.exit(main())
  File "/home/sterengiannini/.local/lib/python2.7/site-packages/tensorflowjs/converters/converter.py", line 317, in main
    strip_debug_ops=FLAGS.strip_debug_ops)
  File "/home/sterengiannini/.local/lib/python2.7/site-packages/tensorflowjs/converters/tf_saved_model_conversion.py", line 289, in convert_tf_saved_model
    input_saved_model_dir=saved_model_dir)
  File "/home/sterengiannini/.local/lib/python2.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 338, in freeze_graph
    input_saved_model_dir, saved_model_tags).graph_def
  File "/home/sterengiannini/.local/lib/python2.7/site-packages/tensorflow/python/tools/saved_model_utils.py", line 42, in get_meta_graph_def
    saved_model = reader.read_saved_model(saved_model_dir)
  File "/home/sterengiannini/.local/lib/python2.7/site-packages/tensorflow/contrib/saved_model/python/saved_model/reader.py", line 55, in read_saved_model
    raise IOError("SavedModel file does not exist at: %s" % saved_model_dir)
IOError: SavedModel file does not exist at: /home/sterengiannini/deepwater/model-js-import-test

以下是模型文件夹中的文件:

$ ls model-js-import-test/
graph.pbtxt  model.ckpt-312.data-00000-of-00001  model.ckpt-312.index  model.ckpt-312.meta

1 个答案:

答案 0 :(得分:1)

该模型似乎没有以正确的格式保存。您应该在模型文件夹(see Structure of a SavedModel directory)中看到以下内容:

assets/
assets.extra/
variables/
    variables.data-?????-of-?????
    variables.index
saved_model.pb|saved_model.pbtxt

例如,如果您使用的是tf.estimator API,则需要使用以下(see Using SavedModel with Estimators)导出模型:

estimator.export_savedmodel(export_dir_base, serving_input_receiver_fn)