machinelearning: TensorFlow exception triggered while loading model
System information
- OS version/distro: Windows 10.0.17763 Enterprise (version: 1809) (x64)
- .NET Version (eg., dotnet --info): .NET Framework 4.7.2 (.NET Core 3.0.0-preview3-27503-5)
Issue
- What did you do? I have tried to load the custom tensorflow model of YoloV2 full.
- What happened? Loading of tensorflow model failed with an generic error.
- What did you expect? Model to be succesfully loaded and used for object detection. As my model was converted via DarkFlow without any errors.
Source code / logs
// Create IDataView from empty list to obtain input data schema
var data = mlContext.Data.LoadFromEnumerable(new List<ImageNetData>());
// Define scoring pipeline
var pipeline = mlContext.Transforms.LoadImages(outputColumnName: "input", imageFolder: imagesFolder, inputColumnName: nameof(ImageNetData.ImagePath))
.Append(mlContext.Transforms.ResizeImages(outputColumnName: "input", imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: "input"))
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "input"))
.Append(mlContext.Model.LoadTensorFlowModel(modelLocation)
.ScoreTensorFlowModel(outputColumnNames: new[] { "output" }, inputColumnNames: new[] { "input" }, addBatchDimensionInput: true));
// Fit scoring pipeline
var model = pipeline.Fit(data);
TensorFlow exception triggered while loading model from ‘C:\Users\Peter\source\repos\NeuralLink\NeuralLink\bin\Debug\XXXX.pb’
at Microsoft.ML.Transforms.TensorFlow.TensorFlowUtils.LoadTFSession(IExceptionContext ectx, Byte[] modelBytes, String modelFile) at Microsoft.ML.TensorflowCatalog.LoadTensorFlowModel(ModelOperationsCatalog catalog, String modelLocation) at NeuralLink.Core.TensorFlowModelScorer.LoadModel() in C:\Users\Peter\source\repos\NeuralLink\NeuralLink\Core\TensorFlowModelScorer.cs:line 46 at NeuralLink.Pages.Analyze.<UserControl_Initialized>d__7.MoveNext() in C:\Users\Peter\source\repos\NeuralLink\NeuralLink\Pages\Analyze.xaml.cs:line 156
This is a seriouse flaw in ML.NET, I was expecting that it can load any VALID tensorflow model. I can post my model and some training images in case you want to investigate.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (6 by maintainers)
I also faced the same exception. And I found that ImageClassification has dependancy on
SciSharp.TensorFlow.Redist. So, after installing version1.14.0of this package I am able to perform Image classification.@xtremertx That is not correct, you need
SciSharp.TensorFlow.Redistif you want training to happen on the CPU. There is no instruction from training that works on CPU but not GPU, it is just a question of performance. These instructions(on which nuget to use and when) are mentioned in detail in the docs and I have also pasted the relevant snapshot below. Let me know if anything is not clear.@mstfbl What you are suggesting is not correct because it would limit our TensorFlow based APIs to CPU. I have already addressed this issue in my prior reply
CC: @harishsk
@PanwarParamveer https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.vision.imageclassificationtrainer?view=ml-dotnet