Пример #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/ImageClassifier.onnx"));

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

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

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