/YOLOv8

Use YOLOv8 in real-time, for object detection, instance segmentation, pose estimation and image classification, via ONNX Runtime.

Primary LanguageC#MIT LicenseMIT

YOLOv8

Use YOLOv8 in real-time, for object detection, instance segmentation, pose estimation and image classification, via ONNX Runtime

Use

Export from PyTorch

Run the following Python code to export the model to ONNX format:

from ultralytics import YOLO

# Load a model
model = YOLO('path/to/model')

# export the model to ONNX format
model.export(format='onnx', opset=15)

Note: Pay attention to specify opset=15 because the ONNX Runtime currently only supports up to Opset 15.

Use in C# with ONNX Runtime

using var predictor = new YoloV8(model);

var result = predictor.Detect("path/to/image");

Console.WriteLine(result);

Plotting

You can use the following code to predict and plot a image, and save to file:

var image = "path/to/image";

using var predictor = new YoloV8("path/to/model");

var result = predictor.Pose(image);

using var origin = Image.Load<Rgb24>(image);
using var ploted = result.PlotImage(origin);


ploted.Save("./pose_demo.jpg")

Examples:

Detection:

detect_demo!

Pose:

pose_demo!

Segmentation:

seg_demo!

License

MIT License