Created
October 9, 2019 19:05
-
-
Save elbruno/3e1a389b220a72ee0b7f91f6512b0d27 to your computer and use it in GitHub Desktop.
CustomVisionEstimationSampleUsage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// open file as byte array | |
var byteData = GetImageAsByteArray(imageFilePath); | |
// prediction | |
var client = new HttpClient(); | |
using var content = new ByteArrayContent(byteData); | |
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); | |
var response = await client.PostAsync(Url, content); | |
var jsonResponse = await response.Content.ReadAsStringAsync(); | |
// Display results | |
var est = CustomVisionEstimation.FromJson(jsonResponse); | |
var prediction = est.Predictions.OrderByDescending(x => x.Probability).FirstOrDefault(); | |
Console.WriteLine(@$"{prediction.TagName} - {prediction.Probability}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment