# Yolov5Net
YOLOv5 object detection with ML.NET, ONNX
![example](https://raw.githubusercontent.com/techwingslab/yolov5-net/master/img/result.jpg)
## Installation
Run this line from Package Manager Console:
```
Install-Package Yolov5Net -Version 1.1.0
```
For CPU usage run this line from Package Manager Console:
```
Install-Package Microsoft.ML.OnnxRuntime -Version 1.14.1
```
For GPU usage run this line from Package Manager Console:
```
Install-Package Microsoft.ML.OnnxRuntime.Gpu -Version 1.14.1
```
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.
```cs
using var image = await Image.LoadAsync<Rgba32>("Assets/test.jpg");
{
using var scorer = new YoloScorer<YoloCocoP5Model>("Assets/Weights/yolov5n.onnx");
{
var predictions = scorer.Predict(image);
var font = new Font(new FontCollection().Add("C:/Windows/Fonts/consola.ttf"), 16);
foreach (var prediction in predictions) // draw predictions
{
var score = Math.Round(prediction.Score, 2);
var (x, y) = (prediction.Rectangle.Left - 3, prediction.Rectangle.Top - 23);
image.Mutate(a => a.DrawPolygon(new Pen(prediction.Label.Color, 1),
new PointF(prediction.Rectangle.Left, prediction.Rectangle.Top),
new PointF(prediction.Rectangle.Right, prediction.Rectangle.Top),
new PointF(prediction.Rectangle.Right, prediction.Rectangle.Bottom),
new PointF(prediction.Rectangle.Left, prediction.Rectangle.Bottom)
));
image.Mutate(a => a.DrawText($"{prediction.Label.Name} ({score})",
font, prediction.Label.Color, new PointF(x, y)));
}
await image.SaveAsync("Assets/result.jpg");
}
}
```
yolov5-net-master.zip
需积分: 5 116 浏览量
2024-03-03
23:00:37
上传
评论
收藏 41.15MB ZIP 举报
AI普惠行者
- 粉丝: 1664
- 资源: 117
最新资源
- 126641091882064LSPatch.apk
- 5G网络基础培训课件.zip
- 2024-spring-HIT-CS-大作业
- yolo目标检测项目实验
- downloadFile-1.hc
- C++课程设计:基于Qt的航班信息管理系统
- ADS7822UVerilog驱动,前面传的有点问题
- 基于python的高性能爬虫程序,使用了多线程+缓存+xpath实现的,这里以彼-岸图库为例,实现,仅用于学习交流
- 中分辨率成像光谱仪(MODIS)烧毁面积产品信息MODIS-C6-BA-User-Guide-1.2.pdf
- Screenshot_20240427_172613_com.huawei.browser.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈