/YoloPredictorMLDotNet

YoloPredictorMLDotNet that uses OpenCvSharp4 instead of System.Drawing (to make cross platform)

Primary LanguageC#GNU Affero General Public License v3.0AGPL-3.0

YoloPredictorMLDotNet

This project provide following packages:

Package Link
DevKen.YoloPredictor NuGet version (DevKen.YoloPredictor)
DevKen.YoloPredictor.Yolov5 NuGet version (DevKen.YoloPredictor.Yolov5)
DevKen.YoloPredictor.OpenCvBridge NuGet version (DevKen.YoloPredictor.OpenCvBridge)

What is this?

This project is designed to make YOLO intergration with .NET fast, easy and convenient. Programmers don't have to understand details about YOLO or ML, just feed the Predictor with trained moudle and images, then receive the results.

Use in critical projects?

DO NOT do that. This project is still under development and comes with NO guarantee.
Post issues if any problems are found.

Usage example

Predict on Bitmap

//Create a predictor by providing modulepath and a backend.
//Install corresponding OnnxRuntime nuget package.
//For example, you need Microsoft.ML.OnnxRuntime.Gpu for CUDA.
YoloPredictor predictor = new YoloPredictorV5(modulepath, backend:YoloPredictorV5.Backend.CUDA);

//Predict on a Bitmap, then apply NMS and Confidence filter.
var detresult = predictor.Predict((Bitmap)Bitmap.FromFile(picture)).NMSFilter().ConfidenceFilter();

Predict on Mat

Opencv read camera and run prediction.

//Create a predictor by providing modulepath and a backend.
YoloPredictor predictor = new YoloPredictorV5(modulepath, backend:YoloPredictorV5.Backend.CUDA);

//Open video device
VideoCapture vc = new VideoCapture(0);

while (true)
{
  //If frame presents
  if (vc.Read(image))
  {
    //Run detector on that frame, then apply NMSFilter and ConfidenceFilter.
    var detresult = predictor.Predict(image).NMSFilter().ConfidenceFilter();
    //** Do something with detresult here **
  }
}