public async Task <TinyYOLOModelModelOutput> EvaluateAsync(TinyYOLOModelModelInput input) { TinyYOLOModelModelOutput output = new TinyYOLOModelModelOutput(); LearningModelBindingPreview binding = new LearningModelBindingPreview(learningModel); binding.Bind("image", input.image); binding.Bind("grid", output.grid); LearningModelEvaluationResultPreview evalResult = await learningModel.EvaluateAsync(binding, string.Empty); return(output); }
private async Task EvaluteImageAsync(VideoFrame videoFrame, bool isImage) { try { var startTime = DateTime.Now; if (model == null) { var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Model/TinyYOLO.onnx")); if (modelFile != null) { model = new TinyYOLOModelModel(); await MLHelper.CreateModelAsync(modelFile, model); } } var input = new TinyYOLOModelModelInput() { image = videoFrame }; var res = await model.EvaluateAsync(input) as TinyYOLOModelModelOutput; if (res != null) { var boxes = model.ComputeBoundingBoxes(res.grid); await DrawDetectedObjectRectAsync(boxes, isImage); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { previewControl.EvalutionTime = (DateTime.Now - startTime).TotalSeconds.ToString(); }); } } catch (Exception ex) { await AlertHelper.ShowMessageAsync(ex.ToString()); } }