Ejemplo n.º 1
0
        public static async Task <hangulModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            hangulModel learningModel = new hangulModel();

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

            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }
Ejemplo n.º 2
0
        private async void LoadModel()
        {
            //Load a machine learning model
            StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/hangul.onnx"));

            charModel = await hangulModel.CreateFromStreamAsync(modelFile as IRandomAccessStreamReference);

            StorageFile lableFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/2350-common-hangul.txt"));

            charLabel = await FileIO.ReadLinesAsync(lableFile);
        }
Ejemplo n.º 3
0
        private async void modelButton_Click(object sender, RoutedEventArgs e)
        {
            // access `PictureLibrary` only
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".onnx");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                //Load a machine learning model
                StorageFile modelFile = await StorageFile.GetFileFromPathAsync(file.Path);

                charModel = await hangulModel.CreateFromStreamAsync(modelFile as IRandomAccessStreamReference);
            }
        }