Coder Social home page Coder Social logo

yolov5-net's Introduction

Yolov5Net

YOLOv5 object detection with ML.NET, ONNX

example

Installation

Run this line from Package Manager Console:

Install-Package Yolov5Net -Version 1.0.9

For CPU usage run this line from Package Manager Console:

Install-Package Microsoft.ML.OnnxRuntime -Version 1.9.0

For GPU usage run this line from Package Manager Console:

Install-Package Microsoft.ML.OnnxRuntime.Gpu -Version 1.9.0

CPU and GPU packages can't be installed together.

Usage

Yolov5Net contains two COCO pre-defined models: YoloCocoP5Model, YoloCocoP6Model.

If you have custom trained model, then inherit from YoloModel and override all the required properties and methods. See YoloCocoP5Model or YoloCocoP6Model implementation to get know how to wrap your own model.

using var image = Image.FromFile("Assets/test.jpg");

using var scorer = new YoloScorer<YoloCocoP5Model>("Assets/Weights/yolov5s.onnx");

List<YoloPrediction> predictions = scorer.Predict(image);

using var graphics = Graphics.FromImage(image);

foreach (var prediction in predictions) // iterate predictions to draw results
{
	double score = Math.Round(prediction.Score, 2);

	graphics.DrawRectangles(new Pen(prediction.Label.Color, 1),
		new[] { prediction.Rectangle });

	var (x, y) = (prediction.Rectangle.X - 3, prediction.Rectangle.Y - 23);

	graphics.DrawString($"{prediction.Label.Name} ({score})",
		new Font("Arial", 16, GraphicsUnit.Pixel), new SolidBrush(prediction.Label.Color),
		new PointF(x, y));
}

image.Save("Assets/result.jpg");

yolov5-net's People

Contributors

keesschollaart81 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.