tensorflow / java

Java bindings for TensorFlow
Apache License 2.0
785 stars 193 forks source link

how to use importGraphDef to load model.pb file? #508

Closed MrbigBox closed 6 months ago

MrbigBox commented 6 months ago

I want to load a exist model to use. I referred to the following URL: https://github.com/tensorflow/java-models/blob/master/tensorflow-examples-legacy/label_image/src/main/java/LabelImage.java

I use this in my project , and get error in importGraphDef The error is "The method importGraphDef(GraphDef) in the type Graph is not applicable for the arguments (byte[])"

I looked at the definition of importGraphDef in the Graph.class. "/**

It seems that the new importGraphDef now requires data of type GraphDef instead of byte[]. How can I use new importGraphDef to load a model.pb file?

Craigacp commented 6 months ago

GraphDef is a protobuf, so you can construct one from a byte[] with GraphDef.parseFrom(byte[]).

MrbigBox commented 6 months ago

Okay, I understand. Thank you.