Help Needed, NullReferenceException when calling runner.AddInput()
I am trying to infer with a pre-trained model i have created with keras/tensorflow. I am adapting code from the examples to try and achieve. I believe i have adapted the ImageUtils class correctly for my model but i am not sure about the rest.
I am getting a NullReferenceException when calling runner.AddInput()
TensorFlow.TFGraph.this[string].get returned null
var graph = new TFGraph();
var model = File.ReadAllBytes("220318model321flat.pb");
graph.Import(model);
if (graph == null)
{
Console.WriteLine("graph empty");
}
using (var session = new TFSession(graph))
{
var tensor = ImageUtil.CreateTensorFromImageFile("2.png", TFDataType.UInt8);
Console.WriteLine(tensor.GetTensorDimension(1).ToString() + tensor.GetTensorDimension(2).ToString());
if (tensor == null)
{
Console.WriteLine("tensor empty");
}
var runner = session.GetRunner();
runner.AddInput(graph["input"][0], tensor).Fetch(graph["output"][0]);
var output = runner.Run();
var result = output[0];
}
Any help would be much appreciated, thank you.
This means that the specified operation ("input") does not exist in your graph. You can get a list of all operations by calling graph.GetEnumerator().
For future reference, a tutorial from Tensorflow documentation defined the variables input as "Placeholder" and output as "final_result"