Skip to content

No objects detected with yolov5 model #29

@trlsmax

Description

@trlsmax

I trained a custom model with yolov5 and export to onnx format, then convert to synet format.
The following code detected nothing, but the onnx model works fine with detect.py of yolov5.

   Net net;
    net.Load("test.xml", "test.bin");

    net.Reshape(1920, 1920, 1);

    Shape shape = net.NchwShape();

    View original;
    original.Load("test0.png");

    View resized(shape[3], shape[2], original.format);
    Simd::Resize(original, resized, ::SimdResizeMethodArea);

    net.SetInput(resized, 0.0f, 255.0f);

    net.Forward();

    Regions objects = net.GetRegions(original.width, original.height, 0.5f, 0.5f);
    uint32_t white = 0xFFFFFFFF;
    for (size_t i = 0; i < objects.size(); ++i)
    {
        const Region & object = objects[i];
        ptrdiff_t l = ptrdiff_t(object.x - object.w / 2);
        ptrdiff_t t = ptrdiff_t(object.y - object.h / 2);
        ptrdiff_t r = ptrdiff_t(object.x + object.w / 2);
        ptrdiff_t b = ptrdiff_t(object.y + object.h / 2);
        Simd::DrawRectangle(original, l, t, r, b, white);
    }
    original.Save("test0r.ppm");

    return 0;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions