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"

Offen
#779 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PowerShell
Sterne
4.7k
Forks
2.7k
Ø Merge
2 T. 22 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Beispiel Image Classification Predictions und dem Aufruf LoadTensorFlowModel und verfolge dann TensorFlowUtils.LoadTFSessionByModelFilePath bis zu Tensorflow.Graph.Import. Vergleiche die erwartete Inception .pb-Eingabe mit dem gemeldeten Keras SavedModel-Layout. Done sollte das unterstützte Modellformat dokumentieren oder implementieren und einen funktionierenden Pfad oder einen eindeutigen Fehler für nicht unterstützte Dateien bereitstellen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, tensorflow
Bereich
machine-learning
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.