使用 OpenVINO 执行提供程序在 C# 中使用 YOLOv3 进行对象检测
-
此对象检测示例使用了来自 ONNX Model Zoo 的 YOLOv3 深度学习 ONNX 模型。
-
该示例涉及将图像呈现给 ONNX Runtime (RT),ONNX Runtime (RT) 使用 ONNX RT 的 OpenVINO 执行提供程序在 Intel® NCS2 stick (MYRIADX 设备) 上运行推理。该示例使用 ImageSharp 进行图像处理,使用 ONNX Runtime OpenVINO EP 进行推理。
此示例的源代码可在 此处 获取。
如何构建
先决条件
-
安装适用于您的操作系统(Mac、Windows 或 Linux)的 .NET Core 3.1 或更高版本。
-
使用任何示例图像作为示例的输入。
-
从 ONNX Model Zoo 下载最新的 YOLOv3 模型。此示例改编自 ONNX Model Zoo。从 此处 下载最新版本的 YOLOv3 模型。
安装 ONNX Runtime 以使用 OpenVINO 执行提供程序
构建步骤
参考文档
构建包含 openvino 风格的 onnxruntime 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]