将 retrain.py 的输出转换为 tensorflow.js
Convert output of retrain.py to tensorflow.js
How to Retrain an Image Classifier for New Categories 中描述的脚本 retrain.py 是 运行 作为
python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test
并生成了输出文件 /tmp/output_graph.pb
。 Converting this 和
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp/output_graph.pb /tmp/model
失败
IOError: SavedModel file does not exist at: /tmp/output_graph.pb/{saved_model.pbtxt|saved_model.pb}
如果文件 output_graph.pb
重命名为 saved_model.pb
(),则错误变为
RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli
saved_model_cli show --dir .
报告空标签集。
如何解决这个问题?
输入的路径是文件夹的路径,不是文件的路径。考虑以下因素:
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp /tmp/model
正如@Ping Yu 在Retrain image detection with MobileNet 中所暗示的,您可以使用
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/
这将使用保存的模型格式保存模型。
How to Retrain an Image Classifier for New Categories 中描述的脚本 retrain.py 是 运行 作为
python retrain.py --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/2 --image_dir /tmp/test
并生成了输出文件 /tmp/output_graph.pb
。 Converting this 和
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp/output_graph.pb /tmp/model
失败
IOError: SavedModel file does not exist at: /tmp/output_graph.pb/{saved_model.pbtxt|saved_model.pb}
如果文件 output_graph.pb
重命名为 saved_model.pb
(
RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI:
saved_model_cli
saved_model_cli show --dir .
报告空标签集。
如何解决这个问题?
输入的路径是文件夹的路径,不是文件的路径。考虑以下因素:
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp /tmp/model
正如@Ping Yu 在Retrain image detection with MobileNet 中所暗示的,您可以使用
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/
这将使用保存的模型格式保存模型。