public async Task <Inceptionv3ModelOutput> EvaluateAsync(Inceptionv3ModelInput input) { Inceptionv3ModelOutput output = new Inceptionv3ModelOutput(); LearningModelBindingPreview binding = new LearningModelBindingPreview(learningModel); binding.Bind("image", input.image); binding.Bind("classLabel", output.classLabel); binding.Bind("classLabelProbs", output.classLabelProbs); LearningModelEvaluationResultPreview evalResult = await learningModel.EvaluateAsync(binding, string.Empty); return(output); }
private async Task EvaluteImageAsync(VideoFrame videoFrame) { try { var startTime = DateTime.Now; if (model == null) { var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Model/Inceptionv3.onnx")); if (modelFile != null) { model = new Inceptionv3Model(); await MLHelper.CreateModelAsync(modelFile, model); } } var input = new Inceptionv3ModelInput() { image = videoFrame }; var res = await model.EvaluateAsync(input) as Inceptionv3ModelOutput; if (res != null) { var results = new List <LabelResult>(); foreach (var kv in res.classLabelProbs) { results.Add(new LabelResult { Label = kv.Key, Result = (float)Math.Round(kv.Value * 100, 2) }); } results.Sort((p1, p2) => { return(p2.Result.CompareTo(p1.Result)); }); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { previewControl.EvalutionTime = (DateTime.Now - startTime).TotalSeconds.ToString(); outputText.Text = res.classLabel.FirstOrDefault(); resultList.ItemsSource = results; }); } } catch (Exception ex) { await AlertHelper.ShowMessageAsync(ex.ToString()); } }