MicrosoftDocs / windows-ai-docs

Windows AI docs
Creative Commons Attribution 4.0 International
13 stars 36 forks source link

please update documentation with the new "LearningModelSession" approach #6

Closed guybartal closed 5 months ago

guybartal commented 5 years ago

this tutorial doesn't work anymore with the new version of ONNX model 1.3, please update documentation with the new "LearningModelSession" approach:

        // create a binding object from the session
        LearningModelBinding binding = new LearningModelBinding(_session);

        //Bind model input with contents from InkCanvas
        VideoFrame vf = await _helper.GetHandWrittenImage(inkGrid);
        ImageFeatureValue imageTensor = ImageFeatureValue.CreateFromVideoFrame(vf);
        binding.Bind("Input3", imageTensor);

        //Evaluate the model
        int ticks = Environment.TickCount;

        // Process the frame with the model
        var results = await _session.EvaluateAsync(binding, $"Run { ++_runCount } ");

        ticks = Environment.TickCount - ticks;
        string message = $"Run took { ticks } ticks";

        // retrieve results from evaluation
        var resultTensor = results.Outputs["Plus214_Output_0"] as TensorFloat;
        var resultVector = resultTensor.GetAsVectorView();

        IList<float> imageList = resultVector.ToList();

        ////Query to check for highest probability digit
        var maxIndex = imageList.IndexOf(imageList.Max());

        ////Display the results
        numberLabel.Text = maxIndex.ToString();

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

QuinnRadich commented 5 months ago

This repo has changed significantly since this issue was first raised, and further changes are upcoming. As such, I'm going through and closing many of these stale issues which sat unassigned for a long while.