yolov5-net icon indicating copy to clipboard operation
yolov5-net copied to clipboard

Custom Model Setup

Open EXINEF opened this issue 2 years ago • 2 comments

Hello guys, I am new to these libraries, I have problems with the C# sharp file to config the custom model, probably I have set up bad the Anchors, Strides, and other stuff cause I did not understand how to set up those values.

This is the Class that extends the abstract Class YoloModel and I will load my model as file:

public class Class1 : YoloModel { public override int Width { get; set; } = 640;

    public override int Height { get; set; } = 640;


    public override int Depth { get; set; } = 3;


    public override int Dimensions { get; set; } = 10;


    public override int[] Strides { get; set; } = new int[3] { 8, 16, 32 };

FLOW_CONTROL_1

    public override int[][][] Anchors { get; set; } = new int[3][][]
    {
        new int[3][]
        {
            new int[2] { 10, 13 },
            new int[2] { 16, 30 },
            new int[2] { 33, 23 }
        },
        new int[3][]
        {
            new int[2] { 30, 61 },
            new int[2] { 62, 45 },
            new int[2] { 59, 119 }
        },
        new int[3][]
        {
            new int[2] { 116, 90 },
            new int[2] { 156, 198 },
            new int[2] { 373, 326 }
        }
    };


    public override int[] Shapes { get; set; } = new int[3] { 80, 40, 20 };


    public override float Confidence { get; set; } = 0.2f;


    public override float MulConfidence { get; set; } = 0.25f;


    public override float Overlap { get; set; } = 0.45f;


    public override string[] Outputs { get; set; } = new string[1] { "output" };


    public override List<YoloLabel> Labels { get; set; } = new List<YoloLabel>
    {
        new YoloLabel
        {
            Id = 1,
            Name = "c22_ok"
        },
        new YoloLabel
        {
            Id = 2,
            Name = "c22_wrong"
        },
        new YoloLabel
        {
            Id = 3,
            Name = "c23_ok"
        },
        new YoloLabel
        {
            Id = 4,
            Name = "c23_wrong"
        }
    };


    public override bool UseDetect { get; set; } = true;

FLOW_CONTROL_1 }

EXINEF avatar Aug 19 '22 14:08 EXINEF

Your stride is going to be 8,16,32 shapes are gonna be 80,40,20 and dimensions are gonna be how many Labels you have +5 which in your case looks to be 9

Jcrueger avatar Aug 21 '22 14:08 Jcrueger

I didn't understand why those values but thank you so much for helping me.

EXINEF avatar Aug 23 '22 09:08 EXINEF