我已经使用tensorflowjs-converter导出了一个预先训练好的deeplab v3模型。我找出了output_node_name,并使用以下命令量化并导出模型
tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='SemanticPredictions' --quantization_bytes 1 --saved_model_tags=serve frozen_inference_graph.pb deeplab_web_model_quant模型已导出,并且我具有以下目录结构
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard1of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard2of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard3of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard4of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard5of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard6of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard7of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard8of10
-rw-rw-r-- 1 ubuntu ubuntu 4194304 Jan 28 20:41 group1-shard9of10
-rw-rw-r-- 1 ubuntu ubuntu 3257567 Jan 28 20:41 group1-shard10of10
-rw-rw-r-- 1 ubuntu ubuntu 94668 Jan 28 20:41 weights_manifest.json
-rw-rw-r-- 1 ubuntu ubuntu 263831 Jan 28 20:41 tensorflowjs_model.pb因此,我在本地压缩此目录传输,并使用以下代码加载导出的模型
const model = await tf.loadFrozenModel(
'http://localhost:8080/tensorflowjs_model.pb',
'http://localhost:8080/weights_manifest.json');我得到一个奇怪的错误,如下所示:
graph_executor.ts:382 Uncaught (in promise) Error: The dict provided in model.execute(dict) has the keys [], but is missing the required keys: [ImageTensor].
at e.checkInput (graph_executor.ts:382)
at e.execute (graph_executor.ts:148)
at e.execute_ (frozen_model.ts:204)
at e.predict (frozen_model.ts:155)
at HTMLButtonElement.runButton.onclick (index.js:13)我更深入地研究了这个ImageTensor的全部内容。它在模型中作为输入张量名称列出。但是,在仅导出output_node_names时,可以指定。有没有什么方法可以调试这个?我不知道如何继续,因为错误消息没有透露太多信息。
谢谢你的帮助。
发布于 2019-01-30 02:11:52
FrozenModel中的predict方法有如下签名:
predict(
inputs: tfc.Tensor|tfc.Tensor[]|tfc.NamedTensorMap,
config?: tfc.ModelPredictConfig): tfc.Tensor
|tfc.Tensor[]|tfc.NamedTensorMap在调用预测方法时,您需要提供输入张量作为第一个参数,该值应该与您的python模型的ImageTensor定义相对应。
https://stackoverflow.com/questions/54410238
复制相似问题