Example #1
0
        // A method to load a machine learning model.
        private async Task loadModel()
        {
            // Get an access the ONNX model and save it in memory.
            StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/bestModel.onnx"));

            // Instantiate the model.
            modelGen = await bestModelModel.CreateFromStreamAsync(modelFile);
        }
Example #2
0
        public static async Task <bestModelModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            bestModelModel learningModel = new bestModelModel();

            learningModel.model = await LearningModel.LoadFromStreamAsync(stream);

            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }