Skip to content

Issue with custom yolov5 models in Winforms after publishing #79

@TheRedAppl

Description

@TheRedAppl

Hi there, I was attempting to publish a solution on winforms with a custom yolov5 model but it seems that loading the model causes the published application to not work. Here is an example of a program in which the published application failed (The custom model only detects one object).
`using System.Windows.Forms;
using Yolov5Net.Scorer;
using Yolov5Net.Scorer.Models.Abstract;

namespace yolov5netproblems
{
public partial class Form1 : Form
{
public class CustomDetector : YoloModel
{
public override int Width { get; set; } = 320;
public override int Height { get; set; } = 320;
public override int Depth { get; set; } = 3;

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

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

        public override int[][][] Anchors { get; set; } = new int[][][]
        {
        new int[][] { new int[] { 010, 13 }, new int[] { 016, 030 }, new int[] { 033, 023 } },
        new int[][] { new int[] { 030, 61 }, new int[] { 062, 045 }, new int[] { 059, 119 } },
        new int[][] { new int[] { 116, 90 }, new int[] { 156, 198 }, new int[] { 373, 326 } }
        };

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

        public override float Confidence { get; set; } = 0.4f; //0.8f 0.25f
        public override float MulConfidence { get; set; } = 0.25f;
        public override float Overlap { get; set; } = 0.45f;

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

        public override List<YoloLabel> Labels { get; set; } = new List<YoloLabel>()
    {
        new YoloLabel { Id = 1, Name = "custom" }
    };

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

        public CustomDetector()
        {

        }
    }
    YoloScorer<CustomDetector> scorer = new YoloScorer<CustomDetector>(@"custom.onnx");
    public Form1()
    {
        InitializeComponent();
    }
}

}
``
Do note that the program does work when being run on visual studio but fails when published

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions