[英]Convert output of retrain.py to tensorflow.js
在如何為新類別重新編寫圖像分類器中描述的腳本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
。 轉換它
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model /tmp/output_graph.pb /tmp/model
失敗了
IOError:SavedModel文件不存在於:/tmp/output_graph.pb/{saved_model.pbtxt|saved_model.pb}
如果文件output_graph.pb
重命名為saved_model.pb
( 由@edkeveked ),則錯誤將更改為
RuntimeError:在SavedModel中找不到與標記'serve'關聯的MetaGraphDef。 要檢查SavedModel中的可用標記集,請使用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在使用MobileNet進行Retrain圖像檢測時所暗示的 ,您可以使用
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/
這將使用保存的模型格式保存模型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.