Git Product home page Git Product logo

Comments (10)

FunJoo avatar FunJoo commented on May 23, 2024

I compared the source code of this repository with sstainba/Yolov8.Net and noticed a difference here. You've used padding. What's the purpose of this padding? Could this be the reason for the false positives?
004

from yolov8.

FunJoo avatar FunJoo commented on May 23, 2024

My test image has an original resolution of 1280x960, my model size is 640x640.

In this repository, after resizing, my test image is 640x480, and through breakpoint inspection, I found the yPadding used is 80.
005

I noticed that sstainba/Yolov8.Net's approach during preprocessing is to directly resize my test image to 640x640 and then scale the bounding boxes in the output to correspond to the original dimensions and size.
007
006

from yolov8.

dme-compunet avatar dme-compunet commented on May 23, 2024

The purpose of padding is to improve the results, because when the aspect ratio remains the same as the original image the predictions are more accurate.

It would be good if you give me a minimal way to reproduce the problem at my, and I hope I can fix it soon

from yolov8.

FunJoo avatar FunJoo commented on May 23, 2024

@dme-compunet
I think sending you my .onnx model and test images for testing would be the most straightforward. You can compare the results from running this repository to those from running python YOLOv8.
How would you recommend receiving the images? Via e-mail, OneDrive/Google Drive, or is there a file-sharing website you'd recommend?

from yolov8.

dme-compunet avatar dme-compunet commented on May 23, 2024

@FunJoo Google Drive is excellent for me

from yolov8.

FunJoo avatar FunJoo commented on May 23, 2024

@dme-compunet https://drive.google.com/drive/folders/1to6dEr7hXMTRaoOtAH-iyDZjcC2aU4OU?usp=sharing

from yolov8.

dme-compunet avatar dme-compunet commented on May 23, 2024

@FunJoo a temporary solution for you is to change the YoloV8.Preprocess method to something like this:

private Tensor<float> Preprocess(Image<Rgb24> image)
{
    var modelSize = _metadata.ImageSize;

    var ratio = Math.Min((float)modelSize.Width / image.Width, (float)modelSize.Height / image.Height);

    var processSize = new Size((int)(image.Width * ratio), (int)(image.Height * ratio));

    var xPadding = (modelSize.Width - processSize.Width) / 2;
    var yPadding = (modelSize.Height - processSize.Height) / 2;

    image.Mutate(x => x.Resize(processSize));

    var dimensions = new int[] { 1, 3, modelSize.Height, modelSize.Width };
    var input = new DenseTensor<float>(dimensions);

    input.Fill(1f); // fill padding background with white color

    image.ForEachPixel((point, pixel) =>
    {
        var x = point.X + xPadding;
        var y = point.Y + yPadding;

        var r = pixel.R / 255f;
        var g = pixel.G / 255f;
        var b = pixel.B / 255f;

        input[0, 0, y, x] = r;
        input[0, 1, y, x] = g;
        input[0, 2, y, x] = b;
    });

    return input;
}

(the input.Fill(1f); was added)

Your problem was that the model predicted the black padding as a vessels, maybe the right solution is to padding the image with a stretch of the last row of pixels to the end, in addition to adding PreprocessWithAspectRatio property to YoloV8Parameters that will give the possibility to perform pre-processing without the use of padding.

from yolov8.

FunJoo avatar FunJoo commented on May 23, 2024

@dme-compunet Thank you, I will take this as my temporary solution. It indeed avoids the false positives, but the preprocessing adds 20~40 milliseconds.

from yolov8.

dme-compunet avatar dme-compunet commented on May 23, 2024

@FunJoo I updated the repo, now the default is processing without keeping original aspect ratios, to process with original aspect ratios (sometimes improves the prediction results) you need to change the ProcessWithOriginalAspectRatio property in YoloV8Parameters to true

from yolov8.

FunJoo avatar FunJoo commented on May 23, 2024

@dme-compunet I've already updated and successfully implemented it. Thank you so much :)

from yolov8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.