// 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); }
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); }
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); }