Constructor with Graph for TensorFlowInferenceInterface (#12669)

Added a new Constructor with `Graph` object only, it will be very useful when user is doing some custom graph loading.

Signature:
`public TensorFlowInferenceInterface(Graph g)`
This commit is contained in:
resec 2017-09-17 15:39:42 -05:00 committed by drpngx
parent 7aa94908e0
commit 74cfc64734

View File

@ -160,6 +160,22 @@ public class TensorFlowInferenceInterface {
}
}
/*
* Construct a TensorFlowInferenceInterface with provided Graph
*
* @param g The Graph to use to construct this interface.
*/
public TensorFlowInferenceInterface(Graph g) {
prepareNativeRuntime();
// modelName is redundant here, here is for
// avoiding error in initialization as modelName is marked final.
this.modelName = "";
this.g = g;
this.sess = new Session(g);
this.runner = sess.runner();
}
/**
* Runs inference between the previously registered input nodes (via feed*) and the requested
* output nodes. Output nodes can then be queried with the fetch* methods.