YoloDotNet

NickSwardhMIT活跃维护

基于 .NET 8 的 C# 视觉推理库,用 ONNX Runtime 或 TensorRT 跑 YOLO 模型,支持图像和实时视频的分类、检测、OBB、分割与姿态估计。

YoloDotNet - A C# .NET 8.0 project for Classification, Object Detection, OBB Detection, Segmentation and Pose Estimation in both images and live video streams.

暂无版本856star +3 / 7 天153fork同步于 2026-11-10 17:55 UTC

怎么上手

由 README 提炼,执行前请确认
dotnet add package YoloDotNet
dotnet add package YoloDotNet.ExecutionProvider.Cpu
硬件要求按 README 说明

CPU 可在 Windows、Linux、macOS 上运行;GPU 加速可选 CUDA/TensorRT、OpenVINO(Windows/Linux)、DirectML(仅 Windows)、CoreML(仅 macOS)。README 未说明具体显存要求。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

纯 .NET 的 YOLO 推理库,无需 Python,覆盖检测、分割、姿态等任务

基于 .NET 8 的 C# 视觉推理库,用 ONNX Runtime 或 TensorRT 跑 YOLO 模型,支持图像和实时视频的分类、检测、OBB、分割与姿态估计。

核心能力

  • 基于 ONNX Runtime 与 SkiaSharp,不依赖 OpenCV
  • 支持检测、OBB、分割、姿态、分类五类任务
  • 执行后端拆成独立 NuGet 包,按需选 CPU 或 GPU
  • 支持 ROI 区域推理与结果导出 JSON、YOLO 标注格式
  • 提供引擎缓存,适合长时间运行的服务

容易踩的坑

执行后端包只能引用一个,混用会导致原生运行时冲突;项目不附带模型,需自行导出 ONNX,YOLOv5u–v12 用 opset=17、YOLOv26 用 opset=18;Ultralytics 导出的模型多为 AGPL-3.0,商用需自行确认授权。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    YoloDotNet v4.2 🚀

    Blazing-fast, production-ready YOLO inference for .NET

    YoloDotNet is a modular, lightweight C# library for real-time computer vision and YOLO-based inference in .NET.

    It provides high-performance inference for modern YOLO model families (YOLOv5u through YOLOv26, YOLO-World, YOLO-E, and RT-DETR), with explicit control over execution, memory, and preprocessing.

    Built on .NET 8, ONNX Runtime, and SkiaSharp, YoloDotNet intentionally avoids heavy computer vision frameworks such as OpenCV.
    There is no Python runtime, no hidden preprocessing, and no implicit behavior — only the components required for fast, predictable inference on Windows, Linux, and macOS.

    No Python. No magic. Just fast, deterministic YOLO — done properly for .NET.

    ⭐ Why YoloDotNet?

    YOLOv5u YOLOv8-v26 YOLO-RT-DETR YOLO-World YOLO-E

    YoloDotNet is designed for developers who need:

    • ✅ Pure .NET — no Python runtime, no scripts
    • ✅ Real performance — CPU, CUDA / TensorRT, OpenVINO, CoreML, DirectML
    • ✅ Explicit configuration — predictable accuracy and memory usage
    • ✅ Production readiness — engine caching, long-running stability
    • ✅ Multiple vision tasks — detection, OBB, segmentation, pose, classification

    Ideal for desktop apps, backend services, and real-time vision pipelines that require deterministic behavior and full control.

    🆕 What’s New v4.2

    • Added Region of Interest (ROI) support, allowing inference to run on selected areas of an image or video stream
      (useful for surveillance, monitoring zones, and performance-focused pipelines)
    • Added the option to draw edges on segmented objects for improved visual clarity
    • Added helper methods for JSON export:
      • ToJson() — convert inference results to JSON
      • SaveJson() — save inference results directly to a JSON file
    • Added helper methods for YOLO-formatted annotations:
      • ToYoloFormat() — convert results to YOLO annotation format
      • SaveYoloFormat() — save results as YOLO-compatible training data
    • Added GetContourPoints() helper for extracting ordered contour points from segmented objects
    • Updated YOLOv26 inference execution to align with other tasks, improving consistency and overall execution efficiency

    📖 Full release history: CHANGELOG.md

    [!TIP] See the demos
    Practical, runnable examples showcasing YoloDotNet features are available in the demo projects:
    👉 Browse the demo folder

    🚀 Quick Start

    💡 ONNX Model Export Requirements

    • For YOLOv26 models, export with opset=18
    • For YOLOv5u–YOLOv12, export with opset=17

    [!IMPORTANT] Using the correct opset ensures optimal compatibility and performance with ONNX Runtime.
    For more information on how to export models to ONNX, refer to https://docs.ultralytics.com/modes/export/

    Example export commands (Ultralytics CLI):

    # For YOLOv5u–YOLOv12 (opset 17)
    yolo export model=yolov8n.pt format=onnx opset=17
    
    # For YOLOv26 (opset 18)
    yolo export model=yolo26n.pt format=onnx opset=18
    

    [!WARNING] Model License Notice:
    YoloDotNet is MIT licensed, but most Ultralytics YOLO models are AGPL-3.0 or require a commercial license for commercial use.
    You are responsible for ensuring your use of any model complies with its license.
    See Ultralytics Model Licensing for details.

    1️⃣ Install the core package

    dotnet add package YoloDotNet
    

    2️⃣ Install exactly one(!) execution provider

    # CPU (recommended starting point)
    dotnet add package YoloDotNet.ExecutionProvider.Cpu
    
    # Hardware-accelerated execution (choose one)
    dotnet add package YoloDotNet.ExecutionProvider.Cuda
    dotnet add package YoloDotNet.ExecutionProvider.OpenVino
    dotnet add package YoloDotNet.ExecutionProvider.CoreML
    dotnet add package YoloDotNet.ExecutionProvider.DirectML
    

    💡 Note: The CUDA execution provider includes optional TensorRT acceleration.
    No separate TensorRT package is required.

    3️⃣ Run object detection

    using SkiaSharp;
    using YoloDotNet;
    using YoloDotNet.Models;
    using YoloDotNet.Extensions;
    using YoloDotNet.ExecutionProvider.Cpu;
    
    using var yolo = new Yolo(new YoloOptions
    {
        ExecutionProvider = new CpuExecutionProvider("model.onnx")
    });
    
    using var image = SKBitmap.Decode("image.jpg");
    
    // Note: The IoU parameter is used for NMS-based models.
    // For YOLOv10 and YOLOv26, IoU is ignored since post-processing is handled internally by the model.
    var results = yolo.RunObjectDetection(image, confidence: 0.25, iou: 0.7);
    
    image.Draw(results);
    image.Save("result.jpg");
    

    You’re now running YOLO inference in pure C#.

    💡 Important: Accuracy Depends on Configuration

    YOLO inference accuracy is not automatic.

    Preprocessing settings such as image resize mode, sampling method, and confidence/IoU thresholds must match how the model was trained.
    These settings directly control the accuracy–performance tradeoff and should be treated as part of the model itself.

    📖 Before tuning models or comparing results, read:
    👉 Accuracy & Configuration Guide

    Supported Tasks

    ClassificationObject DetectionOBB DetectionSegmentationPose Estimation
    pexels.compexels.compexels.compexels.compexels.com

    ✅ Verified YOLO Models

    The following YOLO models have been tested and verified with YoloDotNet using official Ultralytics exports and default heads.

    ClassificationObject DetectionSegmentationPose EstimationOBB Detection
    YOLOv8-clsYOLOv11-clsYOLOv12-clsYOLOv26-clsYOLOv5uYOLOv8YOLOv9YOLOv10YOLOv11YOLOv12YOLOv26RT-DETRYOLOv8-segYOLOv11-segYOLOv12-segYOLOv26-segYOLO-World (v2)YOLOv8-poseYOLOv11-poseYOLOv12-poseYOLOv26-poseYOLOv8-obbYOLOv11-obbYOLOv12-obbYOLOv26-obb

    📁 Demos

    Hands-on examples are available in the demo folder:

    👉 Browse the demo projects

    Includes image inference, video streams, GPU acceleration, segmentation, and large-image workflows.

    Execution Providers

    ProviderWindowsLinuxmacOSDocumentation
    CPU✅✅✅CPU README
    CUDA / TensorRT✅✅❌CUDA README
    OpenVINO✅✅❌OpenVINO README
    CoreML❌❌✅CoreML README
    DirectML✅❌❌DirectML README

    ℹ️ Only one execution provider package may be referenced.
    Mixing providers will cause native runtime conflicts.

    ⚡ Performance Characteristics

    YoloDotNet focuses on stable, low-overhead inference where runtime cost is dominated by the execution provider and model.

    📊 Benchmarks: /test/YoloDotNet.Benchmarks

    • Stable latency after warm-up
    • Clean scaling from CPU → GPU → TensorRT
    • Predictable allocation behavior
    • Suitable for real-time and long-running services

    🚀 Modular Execution Providers

    • Core package is provider-agnostic
    • Execution providers are separate NuGet packages
    • Native ONNX Runtime dependencies are isolated

    Why this matters: fewer conflicts, predictable deployment, and production-safe behavior.

    Support YoloDotNet

    ⭐ Star the repo
    💬 Share feedback
    🤝 Sponsor development

    GitHub Sponsors
    PayPal

    License

    MIT License

    Copyright (c) Niklas Swärd

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


    Model Licensing & Responsibility

    • YoloDotNet is licensed under the MIT License and provides an ONNX inference engine for YOLO models exported using Ultralytics YOLO tooling.

    • This project does not include, distribute, download, or bundle any pretrained models.

    • Users must supply their own ONNX models.

    • YOLO ONNX models produced using Ultralytics tooling are typically licensed under AGPL-3.0 or a separate commercial license from Ultralytics.

    • YoloDotNet does not impose, modify, or transfer any license terms related to user-supplied models.

    • Users are solely responsible for ensuring that their use of any model complies with the applicable license terms, including requirements related to commercial use, distribution, or network deployment.