我按照此处的说明将使用 Python 生成的 Tensorflow 模型导入到 Tensorflow.js 中。
该模型是使用tf.estimator
API创建的,该 API 会根据此页面自动保存模型文件。
使用 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