Python 将retain.py的输出转换为tensorflow.js

Python 将retain.py的输出转换为tensorflow.js,python,tensorflow,tensorflow.js,tensorflow-hub,tensorflowjs-converter,Python,Tensorflow,Tensorflow.js,Tensorflow Hub,Tensorflowjs Converter,中所述的脚本retain.py作为 python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test 并生成输出文件/tmp/output\u graph.pb。与 失败于 IOError:SavedModel文件不存在于:/tmp/output_graph.pb/{saved_model.pbtxt|sav

中所述的脚本retain.py作为

python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test
并生成输出文件
/tmp/output\u graph.pb
。与

失败于

IOError:SavedModel文件不存在于:/tmp/output_graph.pb/{saved_model.pbtxt|saved_model.pb}

如果文件
output_graph.pb
重命名为
saved_model.pb
(),则错误更改为

运行时错误:在SavedModel中找不到与标记“serve”关联的MetaGraphDef。要检查SavedModel中的可用标记集,请使用SavedModel CLI:
saved\u model\u CLI

saved\u model\u cli show--dir.
报告一个空标记集


如何解决这个问题?

输入路径是文件夹的路径,而不是文件的路径。考虑以下事项:

tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp /tmp/model
正如@Ping Yu in所暗示的,您可以使用

python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 \
    --image_dir /tmp/flower_photos --saved_model_dir /tmp/saved_retrained_model
tensorflowjs_converter --input_format=tf_saved_model \
    --output_format=tfjs_graph_model \
    --saved_model_tags=serve \
    /tmp/saved_retrained_model/ /tmp/converted_model/

这将使用保存的模型格式保存模型。

错误说明了一切。该文件不可用found@edkeveked:文件
/tmp/output\u graph.pb
output\u labels.txt
一起存在。这是另一种格式吗?你解决了吗?我在使用tfjs示例时遇到了相同的问题@季谢尔: 不,替代方案也失败了。即使是对他的赏金也没有结果。见@季谢尔: 请参阅更改目录并重命名
.pb
文件后,会发生另一个错误。请参见编辑。仍然是朝着正确方向迈出的一步。谢谢虽然我不能确切地告诉您当前出现错误的原因,但我可以建议将其他标志添加到tfjs转换器命令中。这两个标志一起生成“TensorFlow.js模型转换器”:错误:无法识别的参数:--output\u node\u names=“final\u result”,
--saved\u model\u tags=service
,跳过导致相同“RuntimeError:在SavedModel中找不到与标记“serve”关联的MetaGraphDef。若要检查SavedModel中的可用标记集,请使用SavedModel CLI:
saved\u model\u CLI
python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 \
    --image_dir /tmp/flower_photos --saved_model_dir /tmp/saved_retrained_model
tensorflowjs_converter --input_format=tf_saved_model \
    --output_format=tfjs_graph_model \
    --saved_model_tags=serve \
    /tmp/saved_retrained_model/ /tmp/converted_model/