1:在c#中加载一个yolov5的初始版本如上图所示。具体的下载连接如下: https://gitcode.com/mirrors/mentalstack/yolov5-net?utm_sourc。
2:配置自己训练的数据集时,需要在yolococoP5Model.cs或者yolococoP6Model.cs文件中修改对应的一些参数。具体如下图所示:
using Yolov5Net.Scorer.Models.Abstract;
namespace Yolov5Net.Scorer.Models;
public record YoloCocoP5Model() : YoloModel(
640,
640,
3,
12, //这里的数据=识别个数+5
new[] { 8, 16, 32 },
new[]
{
new[] { new[] { 010, 13 }, new[] { 016, 030 }, new[] { 033, 023 } },
new[] { new[] { 030, 61 }, new[] { 062, 045 }, new[] { 059, 119 } },
new[] { new[] { 116, 90 }, new[] { 156, 198 }, new[] { 373, 326 } }
},
new[] { 80, 40, 20 },
0.20f,
0.25f,
0.45f,
new[] { "output0" }, //注意onnx模型的输出名称要进行查看,确保一致。否则会出现no matching element
new()
{
new(1, "aphanocapsa"), //根据自己的数据集进行配置
new(2, "cryptomonas"),
new(3, "limnothrix"),
new(4, "navicula"),
new(5, "raphidiopisis"),
new(6, "staurastrum"),
new(7, "unknown")
},
true
);
上面有一个巨坑需要注意:onnx的输出名称不一致也会报错。
查看onnx模型的名字,可以通过netro.app网站进行查看
其他只需要常规配置图片以及模型路径即可。