machinelearning
machinelearning copied to clipboard
Exception during Predict
System Information (please complete the following information):
- OS & Version: Windows 10
- ML.NET Version: ML.NET v1.7.1
- .NET Version: .NET 6.0
- SciSharp.TensorFlow.Redis: 2.3.1 Expected behavior Should able to get prediction
CODE
BitmapImage imageAsBitmap = new BitmapImage(new Uri("D:/ImageToGetPrediction.jpeg")); var encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(imageAsBitmap)); var input = new Input();
using (MemoryStream ms = new MemoryStream()) { encoder.Save(ms); input.Image = ms.ToArray(); } var prediction = _predictor.Predict(input);
STACKTRACE
Error: External component has thrown an exception
STACKTRACE: at Tensorflow.c_api.TF_SessionRun(IntPtr session, TF_Buffer* run_options, TF_Output[] inputs, IntPtr[] input_values, Int32 ninputs, TF_Output[] outputs, IntPtr[] output_values, Int32 noutputs, IntPtr[] target_opers, Int32 ntargets, IntPtr run_metadata, SafeStatusHandle status)
at Microsoft.ML.TensorFlow.TensorFlowUtils.Runner.Run()
at Microsoft.ML.Vision.ImageClassificationModelParameters.Classifier.Score(VBuffer1& image, Span1 classProbabilities)
at Microsoft.ML.Vision.ImageClassificationModelParameters.<>c__DisplayClass22_02.<Microsoft.ML.Data.IValueMapper.GetMapper>b__0(VBuffer1& src, VBuffer1& dst) at Microsoft.ML.Data.SchemaBindablePredictorWrapperBase.<>c__DisplayClass19_02.<GetValueGetter>b__0(TDst& dst)
at Microsoft.ML.Data.PredictedLabelScorerBase.EnsureCachedPosition[TScore](Int64& cachedPosition, TScore& score, DataViewRow boundRow, ValueGetter1 scoreGetter) at Microsoft.ML.Data.MulticlassClassificationScorer.<>c__DisplayClass16_0.<GetPredictedLabelGetter>b__1(VBuffer1& dst)
at Microsoft.ML.Data.TypedCursorable1.TypedRowBase.<>c__DisplayClass8_01.<CreateDirectVBufferSetter>b__0(TRow row)
at Microsoft.ML.Data.TypedCursorable1.TypedRowBase.FillValues(TRow row) at Microsoft.ML.Data.TypedCursorable1.RowImplementation.FillValues(TRow row)
at Microsoft.ML.PredictionEngineBase2.FillValues(TDst prediction) at Microsoft.ML.PredictionEngine2.Predict(TSrc example, TDst& prediction)
at Microsoft.ML.PredictionEngineBase`2.Predict(TSrc example)