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"
- Lingua principale
- PowerShell
- Stelle
- 4.7k
- Fork
- 2.7k
- Merge medio
- 2g 22h
- PR unite (30g)
- 1
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con l’esempio Image Classification Predictions e la chiamata LoadTensorFlowModel, quindi segui TensorFlowUtils.LoadTFSessionByModelFilePath fino a Tensorflow.Graph.Import. Confronta l’input Inception .pb previsto con la struttura Keras SavedModel riportata. Done deve documentare o implementare il formato di modello supportato e fornire un percorso funzionante o un errore chiaro per i file non supportati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, tensorflow
- Ambito
- machine-learning
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100