dotnet / dotnet/machinelearning-samples
[Image Classification Predictions (Pretrained TensorFlow model scoring)] Example crashes when loading custom trained .pb model instead of Inception .pb file - "Invalid GraphDef"
- Dominant language
- PowerShell
- Stars
- 4.7k
- Forks
- 2.7k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 1
Description
Hi there,
I tried the "Image Classification Predictions (Pretrained TensorFlow model scoring)" example. When I load the given Inception model, everything works fine. But when I replace the tensorflow_inception_graph.pb file with a different model I trained myself in Keras, the following exception appears when calling the method LoadTensorFlowModel:
`System.FormatException: "Tensorflow exception triggered while loading model." TensorflowException: Invalid GraphDef`
My custom Keras model is saved to a SavedModel format (also a .pb file with some other files) like this:
`tf.saved_model.save(my_custom_model, "/path/to/saved/model")`
Is the .pb file from the saved_model format different from the .pb format of the .pb-file of the inception model? What can I do to fix this?
This is the call stack:
`Tensorflow.Status.Check(bool)`
`Tensorflow.Graph.Import(byte[], string)`
`Tensorflow.Graph.Import(string, string)`
`Microsoft.ML.TensorFlow.TensorFlowUtils.LoadTFSessionByModelFilePath(Microsoft.ML.Runtime.IExceptionContext, string, bool)`
These are the nuget versions of the ML packages:
Microsoft.ML v1.4.0
Microsoft.ML.ImageAnalytics v1.4.0
Microsoft.ML.TensorFlow v1.4.0
SciSharp.TensorFlow.Redist v1.14.0 (also tried v1.15.0)
Target framework is .NET Core 3.1
Any help is much appreciated, thank you in advance
Contributor guide
Assessment
This issue has not been assessed yet.