```
// Create IDataView from empty list to obtain input data schema
var data = mlContext.Data.LoadFromEnumerable(new List
// 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.
_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._
Where can I download the pb model file?
@xtremertx which version of Microsoft.ML.Tensorflow nuget are you using? Looking at the call stack it seems to not be the latest version but want to confirm.
@codemzs I was using the latest nuget package (1.3.1) for .NETStandard 2.0 as I was using .NET Framework.
@Oceania2018
Model downloads:
Tensorflow model
Meta file
Valid input images (should have succesfull detection hit)
661-02536
D661-02536
Model should detect 31 different classes of keyboard layouts.
Netron utility can open the model without any problems.. my guess is that some operation is not supported by tensorflow. In this publlished model I have replaced the ExtractImagePatches op by using SpaceToDepth op instead, however both such models will fail to be loaded by ML.NET.
Error getting while rurring project System.FormatException
HResult=0x80131537
Message=Tensorflow exception triggered while loading model.
Source=Microsoft.ML.TensorFlow
StackTrace:
at Microsoft.ML.TensorFlow.TensorFlowUtils.LoadTFSessionByModelFilePath(IExceptionContext ectx, String modelFile, Boolean metaGraph)
at Microsoft.ML.TensorflowCatalog.LoadTensorFlowModel(ModelOperationsCatalog catalog, String modelLocation)
at TransferLearning.Program.Main(String[] args) in X:\MLProject\MLNetExamples\TransferLearning\Program.cs:line 18
Inner Exception 1:
DllNotFoundException: Unable to load DLL 'tensorflow' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
@PanwarParamveer Have you installed TensorFlow Binary?
Did anyone tried my posted model and got the same error? Any feedback on this issue?
I also faced the same exception. And I found that ImageClassification has dependancy on SciSharp.TensorFlow.Redist.
So, after installing version 1.14.0 of this package I am able to perform Image classification.
Gonna to try that and give you some feedback.
I also experienced the same issue,
After installing the SciSharp.TensorFlow.Redist version 1.14.0 , I am allowed to execute the Image classification.
Hi @xtremertx ,
I downloaded XXXX.pb and the training photos mentioned, and wrote the following test code to diagnose this issue. I also uninstalled the SciSharp.TensorFlow.Redist NuGet package from my build:
public void TensorFlowTempTest()
{
var mlContext = new MLContext(seed: 1);
string modelLocation = @"C:\Users\mubal\Downloads\XXXX.pb";
// 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: @"C:\Users\mubal\Desktop\temp\tmpPics", inputColumnName: nameof(ImageNetData.ImagePath))
.Append(mlContext.Transforms.ResizeImages(outputColumnName: "input", imageWidth: 416, imageHeight: 416, 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);
}
With these, I obtained the following same error that has been reported here:
System.FormatException : Tensorflow exception triggered while loading model.
---- System.DllNotFoundException : Unable to load DLL 'tensorflow' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Stack Trace:
TensorFlowUtils.LoadTFSessionByModelFilePath(IExceptionContext ectx, String modelFile, Boolean metaGraph) line 223
TensorFlowUtils.GetSession(IHostEnvironment env, String modelPath, Boolean metaGraph) line 377
TensorFlowUtils.LoadTensorFlowModel(IHostEnvironment env, String modelPath) line 113
TensorflowCatalog.LoadTensorFlowModel(ModelOperationsCatalog catalog, String modelLocation) line 37
TensorFlowScenariosTests.TensorFlowTempTest() line 146
----- Inner Stack Trace -----
c_api.TF_NewGraph()
Graph.ctor()
TensorFlowUtils.LoadTFSessionByModelFilePath(IExceptionContext ectx, String modelFile, Boolean metaGraph) line 216
I fixed this issue in my PR #5084 by adding SciSharp.TensorFlow.Redist as a dependency to Microsoft.ML.TensorFlow.csproj, so that manual installation of this NuGet package isn't necessary. Thank you all for your contribution on this issue. :D
@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
If I understant correctly, in some cases you need SciSharp.TensorFlow.Redist because some instructions are not implemented on GPU? It would be enough to just mention this in MS docs.
@xtremertx That is not correct, you need SciSharp.TensorFlow.Redist if 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.

In summary, a manual installation of the appropriate SciSharp.TensorFlow.Redist NuGet package is required. This is also stated in docs/api-reference/tensorflow-usage.md. As such, I am closing this issue.
I had the same issue which I tried to solve a lot of time - I downgraded version of SciSharp.TensorFlow.Redist to 1.14.1 and It is working in my case :)
Previously I've used 2.3.0 version
Most helpful comment
I also faced the same exception. And I found that ImageClassification has dependancy on
SciSharp.TensorFlow.Redist.So, after installing version
1.14.0of this package I am able to perform Image classification.