async Task InitCustomVision()
        {
            //setup custom vision clients
            if (!string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionTrainingApiKey) &&
                !string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionPredictionApiKey))
            {
                _customVisionTraining = new CustomVisionTrainingClient {
                    Endpoint = SettingsHelper.Instance.CustomVisionTrainingApiKeyEndpoint, ApiKey = SettingsHelper.Instance.CustomVisionTrainingApiKey
                };
                _customVisionPrediction = new CustomVisionPredictionClient {
                    Endpoint = SettingsHelper.Instance.CustomVisionPredictionApiKeyEndpoint, ApiKey = SettingsHelper.Instance.CustomVisionPredictionApiKey
                };
            }

            //get custom vision projects
            CustomVisionProjects.Clear();
            if (_customVisionTraining != null)
            {
                var projects = await _customVisionTraining.GetProjectsAsync();

                CustomVisionProjects.AddRange(projects.OrderBy(i => i.Name).Select(i => new ProjectViewModel {
                    Project = i
                }));
            }

            //enable UI
            CustomVisionApi.IsEnabled = _customVisionTraining != null;
        }
예제 #2
0
        async Task InitCustomVision()
        {
            //setup custom vision clients
            if (!string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionTrainingApiKey) &&
                !string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionPredictionApiKey) &&
                !string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionPredictionResourceId))
            {
                _customVisionTraining = new CustomVisionTrainingClient(new Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.ApiKeyServiceClientCredentials(SettingsHelper.Instance.CustomVisionTrainingApiKey))
                {
                    Endpoint = SettingsHelper.Instance.CustomVisionTrainingApiKeyEndpoint
                };
                _customVisionPrediction = new CustomVisionPredictionClient(new Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.ApiKeyServiceClientCredentials(SettingsHelper.Instance.CustomVisionPredictionApiKey))
                {
                    Endpoint = SettingsHelper.Instance.CustomVisionPredictionApiKeyEndpoint
                };
            }

            //get custom vision projects
            CustomVisionProjects.Clear();
            if (_customVisionTraining != null)
            {
                var projects = await _customVisionTraining.GetProjectsAsync();

                CustomVisionProjects.AddRange(projects.OrderBy(i => i.Name).Select(i => new ProjectViewModel {
                    Project = i
                }));
            }

            //enable UI
            CustomVisionApi.IsEnabled = _customVisionTraining != null;
        }