public static async Task <bearModel> CreateFromStreamAsync(IRandomAccessStreamReference stream) { bearModel learningModel = new bearModel(); learningModel.model = await LearningModel.LoadFromStreamAsync(stream); learningModel.session = new LearningModelSession(learningModel.model); learningModel.binding = new LearningModelBinding(learningModel.session); return(learningModel); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/bear.onnx")); classificationModel = await bearModel.CreateFromStreamAsync(modelFile); StorageFile detectionFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/bear-detection.onnx")); detectionModel = new ObjectDetection(new List <string> { "black bear", "brown bear", "polar bear" }); await detectionModel.Init(detectionFile); }