Ejemplo n.º 1
0
        private async void recognizeButton_Click(object sender, RoutedEventArgs e)
        {
            //Bind model input with contents from InkCanvas
            VideoFrame vf = await helper.GetHandWrittenImage(inkGrid);

            inkshapesInput.data = ImageFeatureValue.CreateFromVideoFrame(vf);

            //Evaluate the model
            inkshapesOutput = await modelGen.EvaluateAsync(inkshapesInput);

            var   guessedTag        = inkshapesOutput.classLabel.GetAsVectorView().First();
            var   loss              = inkshapesOutput?.loss?.FirstOrDefault();
            float guessedPercentage = 0f;

            if (loss != null)
            {
                var entry = loss.ToList().OrderByDescending(kv => kv.Value).FirstOrDefault();
                guessedPercentage = entry.Value;
            }

            var text = $"{guessedTag} ({guessedPercentage.ToString("P")})";

            ////Display the results
            numberLabel.Text = text;
        }
Ejemplo n.º 2
0
        public async Task <inkshapesOutput> EvaluateAsync(inkshapesInput input)
        {
            binding.Bind("data", input.data);
            var result = await session.EvaluateAsync(binding, "0");

            var output = new inkshapesOutput();

            output.classLabel = result.Outputs["classLabel"] as TensorString;
            output.loss       = result.Outputs["loss"] as IList <IDictionary <string, float> >;
            return(output);
        }