[英]tensorflow 2.7 load saved model error with java
我用 tf2.7 保存了一個 model 格式的 model 並成功加載:
model = tf.saved_model.load(export_dir=export_dir)
當我使用 saved_model_cli 檢查這個 model 時,它重新返回:
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['examples'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: input_example_tensor:0
The given SavedModel SignatureDef contains the following output(s):
outputs['cf_1'] tensor_info:
dtype: DT_INT64
shape: (-1, 1)
name: ParseExample/ParseExampleV2:0
outputs['cf_2'] tensor_info:
dtype: DT_INT64
shape: (-1, 1)
name: ParseExample/ParseExampleV2:1
outputs['cf_label'] tensor_info:
dtype: DT_INT64
shape: (-1, 1)
name: ParseExample/ParseExampleV2:2
outputs['score'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 1)
name: score:0
Method name is: tensorflow/serving/predict
但是當我嘗試使用 java 來加載這個 model 時,它出錯了:
val bundle = tf.SavedModelBundle.load("/Users/jiyue/git/dl_flow/model_dir_cfck/1646106315","serve")
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow</artifactId>
<version>1.15.0</version>
</dependency>
錯誤是:
Exception in thread "main" org.tensorflow.TensorFlowException: Op type not registered 'ParseExampleV2' in binary running on xxxx. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
我需要有人幫助我解決它,謝謝!
我寫了一個庫來導入和管理保存的模型。 如果你想看看: JavaTF
如果您願意,可以按照我在自述文件中提供的說明進行操作,然后測試功能。
您可以運行 Object 檢測(推理),並獲得檢測結果。您還可以繪制邊界框。
讓我知道是否有幫助:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.