NickSwardh/YoloDotNet

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

YoloDotNet – Fast, pure‑C# YOLO inference for .NET

What it is – A lightweight, modular C# library that runs YOLO‑style computer‑vision models (object detection, segmentation, pose, etc.) on .NET 8 using ONNX Runtime. It ships with separate NuGet packages for each hardware‑accelerated execution provider (CPU, CUDA/TensorRT, OpenVINO, CoreML, DirectML) and avoids any Python or OpenCV dependencies.

Why it matters – .NET developers can now embed state‑of‑the‑art YOLO models in desktop apps, backend services, or real‑time pipelines without pulling in a Python runtime or heavyweight CV stacks. The library gives explicit control over preprocessing, memory, and provider selection, which is useful for production‑grade deployments where latency, stability, and deterministic behavior are critical.


Key Features (as described in the README)

  • Pure .NET – All inference code is C#; no Python, no hidden scripts.
  • Broad model support – Works with YOLOv5u‑v12, YOLOv26, YOLO‑World, YOLO‑E, RT‑DETR, and their task‑specific heads (detection, OBB, segmentation, pose, classification).
  • Multiple execution providers – Choose exactly one of:
    • CPU (default)
    • CUDA / TensorRT (Windows & Linux)
    • OpenVINO (Windows & Linux)
    • CoreML (macOS only)
    • DirectML (Windows only)
  • Deterministic configuration – You supply confidence, IoU, resize mode, etc., matching the model’s training settings.
  • Production‑ready – Engine caching, long‑running stability, predictable memory use.
  • ROI inference – Run detection on a selected region of an image/video, useful for surveillance or performance‑critical pipelines.
  • Convenient helpers – JSON export (ToJson, SaveJson), YOLO‑format export (ToYoloFormat, SaveYoloFormat), contour extraction (GetContourPoints).
  • Demo projects – Ready‑to‑run examples for image, video, GPU acceleration, large‑image workflows.
  • Benchmarks – Included tests show stable latency and clean scaling from CPU to GPU/TensorRT.

Typical Use Cases

  • Desktop vision apps – Real‑time object detection or segmentation inside a Windows/macOS/Linux GUI built with .NET.
  • Backend services – Image‑processing micro‑services that need fast, deterministic inference (e.g., content moderation, inventory analysis).
  • Edge or embedded devices – Deploy on hardware that supports CUDA, OpenVINO, or CoreML while staying within the .NET ecosystem.
  • Surveillance pipelines – Use ROI inference to focus on specific zones and reduce compute load.
  • Research prototyping – Quickly test new YOLO models exported to ONNX without writing any Python glue code.

Getting Started (from the README)

  1. Export an ONNX model from Ultralytics:
    # YOLOv5‑v12 (opset 17)
    yolo export model=yolov8n.pt format=onnx opset=17
    # YOLOv26 (opset 18)
    yolo export model=yolo26n.pt format=onnx opset=18
    
  2. Add the core package to your project:
    dotnet add package YoloDotNet
    
  3. Add exactly one execution‑provider package (CPU is the simplest start):
    dotnet add package YoloDotNet.ExecutionProvider.Cpu   # or .Cuda, .OpenVino, .CoreML, .DirectML
    
  4. Run inference (example for object detection on CPU):
    using SkiaSharp;
    using YoloDotNet;
    using YoloDotNet.ExecutionProvider.Cpu;
    
    var yolo = new Yolo(new YoloOptions {
        ExecutionProvider = new CpuExecutionProvider("model.onnx")
    });
    
    var img = SKBitmap.Decode("image.jpg");
    var results = yolo.RunObjectDetection(img, confidence: 0.25, iou: 0.7);
    img.Draw(results);
    img.Save("result.jpg");
    
  5. Explore the demo folder for video streams, segmentation, pose estimation, and ROI usage.

License & Model Responsibility

  • Code – MIT License (full permission to use, modify, distribute).
  • Models – Not bundled. Users must supply their own ONNX YOLO models, which are typically licensed under AGPL‑3.0 or a commercial Ultralytics license. The README stresses that users are responsible for complying with those model licenses.

Bottom Line

YoloDotNet gives .NET developers a clean, high‑performance way to run modern YOLO models without any Python baggage. Its modular provider system, explicit configuration, and production‑focused features make it suitable for anything from quick prototypes to long‑running services that need reliable, deterministic vision inference.

Related

  • Project
  • Project
  • Project
  • Project