dotnet / machinelearning-samples

Samples for ML.NET, an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
4.48k stars 2.68k forks source link

TFFeaturizerEstimator - Predict expects a different model than what Train produces. #618

Closed BrainSlugs83 closed 5 years ago

BrainSlugs83 commented 5 years ago

This is an issue with the DeepLearning_TensorFlowEstimator solution.

As-is if you you run ImageClassification.Predict, it will work (after you fix the broken relative paths).

But if you Run ImageClassification.Train, and copy the "imageClassifier.zip" into the Predict project over the file that's baked in, it will fail with Could not find input column 'ImageFileName'.

Here is the complete output from ImageClassification.Predict:

Loading model
#############
Model loaded: D:\projects.git\machinelearning-samples\samples\csharp\getting-started\DeepLearning_TensorFlowEstimator\ImageClassification.Predict\bin\x64\Debug\netcoreapp2.1\../../../../assets\inputs\imageClassifier.zip
2019-08-21 19:09:44.476272: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

EXCEPTION
#########
System.ArgumentOutOfRangeException: Could not find input column 'ImageFileName'
Parameter name: inputSchema
   at Microsoft.ML.Data.OneToOneTransformerBase.CheckInput(DataViewSchema inputSchema, Int32 col, Int32& srcCol)
   at Microsoft.ML.Data.OneToOneTransformerBase.OneToOneMapperBase..ctor(IHost host, OneToOneTransformerBase parent, DataViewSchema inputSchema)
   at Microsoft.ML.Data.ImageLoadingTransformer.Mapper..ctor(ImageLoadingTransformer parent, DataViewSchema inputSchema)
   at Microsoft.ML.Data.ImageLoadingTransformer.MakeRowMapper(DataViewSchema schema)
   at Microsoft.ML.Data.RowToRowTransformerBase.Microsoft.ML.ITransformer.GetRowToRowMapper(DataViewSchema inputSchema)
   at Microsoft.ML.Data.TransformerChain`1.Microsoft.ML.ITransformer.GetRowToRowMapper(DataViewSchema inputSchema)
   at Microsoft.ML.PredictionEngineBase`2..ctor(IHostEnvironment env, ITransformer transformer, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at Microsoft.ML.PredictionEngineExtensions.CreatePredictionEngine[TSrc,TDst](ITransformer transformer, IHostEnvironment env, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at ImageClassification.Model.ModelScorer.ClassifyImages() in D:\projects.git\machinelearning-samples\samples\csharp\getting-started\DeepLearning_TensorFlowEstimator\ImageClassification.Predict\Model\ModelScorer.cs:line 34
   at ImageClassification.Predict.Program.Main(String[] args) in D:\projects.git\machinelearning-samples\samples\csharp\getting-started\DeepLearning_TensorFlowEstimator\ImageClassification.Predict\Program.cs:line 23

Press any key to finish.
CESARDELATORRE commented 5 years ago

Thanks for the heads-up. I fixed it in this commit:

https://github.com/dotnet/machinelearning-samples/commit/e688bf52a030c72e1e2765d77ebe22741ec5abbc

Please confirm that it works now from your side. I'm closing the issue, but if you still have issues, feel free to re-open it, ok?