async Task PredictPhoto(MediaFile photo) { var endpoint = new PredictionEndpoint { ApiKey = await KeyService.GetPredictionKey() }; var results = await endpoint.PredictImageAsync(Guid.Parse(await KeyService.GetProjectId()), photo.GetStream()); AllPredictions = results.Predictions .Where(p => p.Probability > Probability) .ToList(); // Create the Api, passing in the training key CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient() { ApiKey = KeyService.TK, Endpoint = KeyService.SouthCentralUsEndpoint }; // Find the object detection domain //var domains = trainingApi.GetDomains(); //var objDetectionDomain = domains.FirstOrDefault(d => d.Type == "ObjectDetection"); //upload to service trainingApi.CreateImagesFromData(Guid.Parse(await KeyService.GetProjectId()), photo.GetStream(), null); }
protected override async void OnStart() { if (string.IsNullOrWhiteSpace(await KeyService.GetPredictionKey()) || string.IsNullOrWhiteSpace(await KeyService.GetProjectId())) { await MainPage.Navigation.PushModalAsync(SettingsPage.CreateSettingsPage(), false); } }
public async Task SetUp() { try { PredictionKey = await KeyService.GetPredictionKey(); ProjectId = await KeyService.GetProjectId(); } finally { IsEnabled = true; } }
async Task PredictPhoto(MediaFile photo) { var endpoint = new PredictionEndpoint { ApiKey = await KeyService.GetPredictionKey() }; var results = await endpoint.PredictImageAsync(Guid.Parse(await KeyService.GetProjectId()), photo.GetStream()); AllPredictions = results.Predictions .Where(p => p.Probability > Probability) .ToList(); }
async Task PredictPhoto(MediaFile photo) { var endpoint = new CustomVisionPredictionClient { ApiKey = await KeyService.GetPredictionKey(), Endpoint = await KeyService.GetEndpoint() }; var results = await endpoint.DetectImageAsync(Guid.Parse(await KeyService.GetProjectId()), await KeyService.GetPublishName(), photo.GetStream()); AllPredictions = results.Predictions .Where(p => p.Probability > Probability) .ToList(); }
public async Task SetUp() { if (string.IsNullOrWhiteSpace(PredictionKey) && string.IsNullOrWhiteSpace(ProjectId) && string.IsNullOrWhiteSpace(PublishName) && string.IsNullOrWhiteSpace(Endpoint)) { try { PredictionKey = await KeyService.GetPredictionKey(); ProjectId = await KeyService.GetProjectId(); PublishName = await KeyService.GetPublishName(); Endpoint = await KeyService.GetEndpoint(); } finally { IsEnabled = true; } } }
public SettingsViewModel() { #pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void OpenCustomVisionCommand = new Command(async() => await Xamarin.Essentials.Launcher.OpenAsync("https://customvision.ai")); OkCommand = new Command(async() => await Ok(), () => !string.IsNullOrWhiteSpace(PredictionKey) && !string.IsNullOrWhiteSpace(ProjectId) && Guid.TryParse(ProjectId, out var g)); ConfigureCanCancelCommand = new Command(async() => CanCancel = !string.IsNullOrWhiteSpace(await KeyService.GetPredictionKey()) && !string.IsNullOrWhiteSpace(await KeyService.GetProjectId())); CancelCommand = new Command(async() => await Application.Current.MainPage.Navigation.PopModalAsync()); #pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void IsEnabled = false; }