forked from microsoft/onnxruntime-csharp-cv-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
34 lines (30 loc) · 1.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Microsoft.ML.OnnxRuntime;
using OnnxRuntime.ResNet.Template.utils;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OnnxRuntime.ResNet.Template
{
class Program
{
public static void Main(string[] args)
{
// Read paths
string modelFilePath = @"C:\code\onnxruntime-templates\onnxruntime-csharp-cv-template\model\resnet50v2.onnx";
string imageFilePath = @"C:\code\onnxruntime-templates\onnxruntime-csharp-cv-template\data\dog.jpeg";
var inputs = ImageHelper.GetImageTensorFromPath(imageFilePath);
foreach (var input in inputs)
{
var top10 = ModelHelper.GetPredictions(input, modelFilePath);
// Print results to console
Console.WriteLine("Top 10 predictions for ResNet50 v2...");
Console.WriteLine("--------------------------------------------------------------");
foreach (var t in top10)
{
Console.WriteLine($"Label: {t.Label}, Confidence: {t.Confidence}");
}
Console.WriteLine();
}
}
}
}