public async Task LoadModelAsync()
        {
            var picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            picker.FileTypeFilter.Add(".model");
            var pickedFile = await picker.PickSingleFileAsync();

            if (pickedFile != null)
            {
                // The file cannot be read directly from the DocumentsLibrary, so copy the file into the local app folder
                var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                var localFile   = await pickedFile.CopyAsync(localFolder, pickedFile.Name, NameCollisionOption.ReplaceExisting);

                var sw = Stopwatch.StartNew();
                console.ShowText("Loading CNTK Model... ");
                console.ShowProgress(true);

                try
                {
                    var path = localFile.Path;
                    this.cntkRecognizer = CNTKImageRecognizer.Create(path, "Assets\\imagenet1000_clsid.txt");
                    sw.Stop();
                    console.ShowText($"Elapsed time: {sw.ElapsedMilliseconds} ms");
                }
                catch (Exception ex)
                {
                    console.ShowText($"error: {ex.Message}");
                    sw.Stop();
                }
                console.ShowProgress(false);
            }
        }
Ejemplo n.º 2
0
        public async Task Start()
        {
            var sw = Stopwatch.StartNew();

            console.ShowText("Loading CNTK Model... ");
            console.ShowProgress(true);

            try
            {
                this.cntkRecognizer = await CNTKImageRecognizer.Create("Assets\\ResNet18_ImageNet_CNTK.model", "Assets\\imagenet1000_clsid.txt");

                sw.Stop();
                console.ShowText($"Elapsed time: {sw.ElapsedMilliseconds} ms");
            }
            catch (Exception ex)
            {
                console.ShowText($"error: {ex.Message}");
                sw.Stop();
            }
            console.ShowProgress(false);
        }
Ejemplo n.º 3
0
        private async Task Run()
        {
            var sw = Stopwatch.StartNew();

            this.text.Text = "Loading CNTK Model... ";

            try
            {
                this.cntkRecognizer = await CNTKImageRecognizer.Create("Assets\\ResNet18_ImageNet_CNTK.model", "Assets\\imagenet1000_clsid.txt");

                sw.Stop();
                this.text.Text += $"Elapsed time: {sw.ElapsedMilliseconds} ms";
                this.cntkPickButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                this.text.Text += $"error: {ex.Message}";
                sw.Stop();
            }

#if false // not using image picker
            var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");

            var files = new String[]
            {
                "broccoli.jpg",
                "cauliflower.jpg",
                "snow-leopard.jpg",
                "timber-wolf.jpg",
                "nile_crocodile_1.jpg",
                "American-alligator.jpg"
            };

            foreach (var fileName in files)
            {
                var file = await folder.GetFileAsync(fileName);
                await RecognizeFile(MLFramework.CNTK, file);
            }
#endif
        }