David Papp
David Papp

Reputation: 139

Loading Tensorflow model in Java

I'm trying to use my trained tensorflow model for object detection in Java. I exported the model (trained with Python) with this script export_inference_graph. This generated a frozen_inference_graph.pb file as well as a saved_model.pb file.

My understanding is that the best way to use this model in Java is to use to load the model via SavedModelBundle.load(). However, when I try this with the saved_model.pb file, I get the error SavedModel not found in export directory:. Is there a better way to load the model in Java for object detection?

Please let me know if you have any suggestions! I suspect that I'm doing something wrong in the process.

Upvotes: 0

Views: 5331

Answers (2)

Cem Pamir Bana
Cem Pamir Bana

Reputation: 31

I have written a library just for that. You can have a look if you want: JavaTF

You can have a model directory with multiple saved_models, and manage them with ModelLoader. It is all described on the Readme.

Let me know if it helps:)

Upvotes: -1

ash
ash

Reputation: 6751

The SavedModel format encodes all model information in a directory, not a file. So you want to provide the directory containing the saved_model.pb file to SavedModelBundle.load(), and not the file itself.

You may find the official sample to be instructive too.

Hope that helps.

Upvotes: 3

Related Questions