使用 OpenVINO 执行提供程序在 C# 中进行 YOLOv3 对象检测
-
此对象检测示例使用了 ONNX 模型库中的 YOLOv3 深度学习 ONNX 模型。
-
该示例涉及向 ONNX Runtime (RT) 提供图像,ONNX Runtime (RT) 使用 OpenVINO 执行提供程序对 Intel® NCS2 棒 (MYRIADX 设备) 进行推理。该示例使用 ImageSharp 进行图像处理,并使用 ONNX Runtime OpenVINO EP 进行推理。
此示例的源代码可在此处获取:此处。
如何构建
先决条件
-
为您的操作系统(Mac、Windows 或 Linux)安装 .NET Core 3.1 或更高版本。
-
使用任何示例图像作为示例的输入。
-
从 ONNX 模型库下载最新的 YOLOv3 模型。此示例改编自 ONNX 模型库。在此处下载 YOLOv3 模型的最新版本。
安装适用于 OpenVINO 执行提供程序的 ONNX Runtime
构建步骤
参考文档
构建带有 OpenVINO 特性的 ONNX Runtime nuget 包
./build.sh --config Release --use_openvino MYRIAD_FP16 --build_shared_lib --build_nuget
构建示例 C# 应用程序
- 创建新的控制台项目
dotnet new console
-
安装 Onnxruntime 和 ImageSharp 的 Nuget 包
- 使用 VS19 打开 Visual C# 项目文件 (.csproj)。
- 右键单击项目,导航到管理 Nuget 包。
- 从 nuget.org 安装 SixLabors.ImageSharp 包。
- 从您的构建目录 nuget-artifacts 中安装 Microsoft.ML.OnnxRuntime.Managed 和 Microsoft.ML.OnnxRuntime.Openvino。
-
编译示例
dotnet build
- 运行示例
dotnet run [path-to-model] [path-to-image] [path-to-output-image]