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; } } }