Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CustomVisionEstimationSampleUsage.cs
// 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
You can’t perform that action at this time.