Ejemplo n.º 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/classifier.onnx"));

            // Instantiate the model.
            modelGen = await classifierModel.CreateFromStreamAsync(modelFile);
        }
Ejemplo n.º 2
0
        public static async Task <classifierModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            classifierModel learningModel = new classifierModel();

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

            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }
Ejemplo n.º 3
0
        public static async Task <classifierModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            classifierModel learningModel = new classifierModel();

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

            // Select GPU or another DirectX device to evaluate the model.
            LearningModelDevice device = new LearningModelDevice(LearningModelDeviceKind.DirectX);

            // Create the evaluation session with the model and device.
            learningModel.session = new LearningModelSession(learningModel.model, device);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }