dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.02k stars 1.88k forks source link

[Image Classification API] TensorFlow exception triggered while loading model #4420

Closed luisquintanilla closed 4 years ago

luisquintanilla commented 4 years ago

System information

Issue

Tried to train a model using Image Classification API and ResNetV2101 architecture.

Source code / logs

Source Code: https://github.com/luisquintanilla/machinelearning-samples/blob/testing-1.4.0-samples/samples/csharp/getting-started/DeepLearning_ImageClassification_Binary/DeepLearning_ImageClassification_Binary/Program.cs

Stack Trace:

   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.Vision.ImageClassificationTrainer.LoadTensorFlowSessionFromMetaGraph(IHostEnvironment env, Architecture arch, String path)
   at Microsoft.ML.Vision.ImageClassificationTrainer.InitializeTrainingGraph(IDataView input)
   at Microsoft.ML.Vision.ImageClassificationTrainer.TrainModelCore(TrainContext trainContext)
   at Microsoft.ML.Trainers.TrainerEstimatorBase`2.TrainTransformer(IDataView trainSet, IDataView validationSet, IPredictor initPredictor)
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
   at DLImageClassificationBinary.Program.Main(String[] args) in C:\Users\luquinta.REDMOND\source\repos\DLImageClassificationBinary\DLImageClassificationBinary\Program.cs:line 60

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)
ashbhandare commented 4 years ago

Was able to reproduce the error. The error occurs because the tensorflow DLL is not found. It can be resolved by installing the appropriate nuget : SciSharp.TensorFlow.Redist ( or SciSharp.TensorFlow.Redist-Windows-GPU for GPU support) (https://github.com/dotnet/machinelearning/blob/master/docs/api-reference/tensorflow-usage.md).