예제 #1
0
파일: hangul.cs 프로젝트: iljoong/winml
        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);
        }
예제 #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);
        }
예제 #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);
            }
        }