Yolov8.Net 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Yolov8.Net --version 1.1.0                
NuGet\Install-Package Yolov8.Net -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yolov8.Net" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Yolov8.Net --version 1.1.0                
#r "nuget: Yolov8.Net, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Yolov8.Net as a Cake Addin
#addin nuget:?package=Yolov8.Net&version=1.1.0

// Install Yolov8.Net as a Cake Tool
#tool nuget:?package=Yolov8.Net&version=1.1.0                

Yolov8.Net

https://github.com/sstainba/Yolov8.Net

This is a .NET interface for using Yolov5 and Yolov8 models on the ONNX runtime. At the time this is published, the ONNX Runtime only supports up to Opset 15. If you are training a custom model, be sure to export the model to the ONNX format with the --Opset=15 flag.

NOTE: If you want to use the GPU, you must have BOTH the CUDA drivers AND CUDNN installed!!!!!! Loading the model is time consuming, so initial predictions will be slow. Subsequent predictions will be significantly faster.

alternate text is missing from this package README image

// Create new Yolov8 predictor, specifying the model (in ONNX format)
// If you are using a custom trained model, you can provide an array of labels. Otherwise, the standard Coco labels are used.
using var yolo = new YoloV8Predictor.Create("./assets/yolov8m.onnx");

// Provide an input image.  Image will be resized to model input if needed.
using var image = Image.FromFile("Assets/rufus.jpg");
var predictions = yolo.Predict(image);

// Draw your boxes
using var graphics = Graphics.FromImage(image);
foreach (var pred in predictions)
{
    var originalImageHeight = image.Height;
    var originalImageWidth = image.Width;

    var x = Math.Max(pred.Rectangle.X, 0);
    var y = Math.Max(pred.Rectangle.Y, 0);
    var width = Math.Min(originalImageWidth - x, pred.Rectangle.Width);
    var height = Math.Min(originalImageHeight - y, pred.Rectangle.Height);

    ////////////////////////////////////////////////////////////////////////////////////////////
    // *** Note that the output is already scaled to the original image height and width. ***
    ////////////////////////////////////////////////////////////////////////////////////////////

    // Bounding Box Text
    string text = $"{pred.Label.Name} [{pred.Score}]";

    using (Graphics graphics = Graphics.FromImage(image))
    {
        graphics.CompositingQuality = CompositingQuality.HighQuality;
        graphics.SmoothingMode = SmoothingMode.HighQuality;
        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

        // Define Text Options
        Font drawFont = new Font("consolas", 11, FontStyle.Regular);
        SizeF size = graphics.MeasureString(text, drawFont);
        SolidBrush fontBrush = new SolidBrush(Color.Black);
        Point atPoint = new Point((int)x, (int)y - (int)size.Height - 1);

        // Define BoundingBox options
        Pen pen = new Pen(Color.Yellow, 2.0f);
        SolidBrush colorBrush = new SolidBrush(Color.Yellow);

        // Draw text on image 
        graphics.FillRectangle(colorBrush, (int)x, (int)(y - size.Height - 1), (int)size.Width, (int)size.Height);
        graphics.DrawString(text, drawFont, fontBrush, atPoint);

        // Draw bounding box on image
        graphics.DrawRectangle(pen, x, y, width, height);
    }
}

alternate text is missing from this package README image

References

https://github.com/ultralytics/yolov8

https://github.com/mentalstack/yolov5-net

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Yolov8.Net:

Repository Stars
codeproject/CodeProject.AI-Server
CodeProject.AI Server is a self contained service that software developers can include in, and distribute with, their applications in order to augment their apps with the power of AI.
Version Downloads Last updated
2.0.0 806 9/9/2024
1.1.4 5,410 8/28/2023
1.1.3 490 8/1/2023
1.1.2 342 7/14/2023
1.1.0 993 6/19/2023
1.0.4 1,660 2/4/2023
1.0.2-alpha.0.4 165 1/31/2023