techwingslab/yolov5-net

Hi, Can it be configured to detect only one of 80 classes?

Closed this issue · 7 comments

image

I have a few questions:

  1. I want to use the original [yolov5n. Onnx] and configure it to detect. For example, in the class of [person], I want to filter during detection, not after the results come out. Can I do this?
  2. Will this increase our detection speed?
  3. If we can't do this, can we only realize it by starting a new training model?

I am a beginner of yolov5. This code example is very helpful to me. Thank you

@luopinluobo you have to train a new model if you need only 1 class, you may change Dimensions, Labels but it won't work, beacuse output tensor will have size of 85 anyway and will contain predictions for all trained classes.

@kkarahainko
Thank you very much for your reply. It seems that we can't directly use some trained models and use their subclasses.
If the new model has only one class, will the prediction speed be significantly improved?

@luopinluobo it depends on what you're going to achieve, number of classes will not significantly improve the detection speed, pay attention to GPU acceleration, Im getting 30+ fps on laptop with rtx 3060, it's enough for tasks like video, stream processing etc.

@luopinluobo im not sure why can't you use pre-trained models )

var persons = predictions.Where(x => x.Label.Name == "person"); persons will containt only "person" predictions

@kkarahainko
I just want to test whether there is a big improvement. Now I have also obtained 30 + FPs in gtx1080ti, but the target machine is gtx1050. I haven't tested whether it can be met, so I want to find out whether there is any way to improve the speed. If the speed meets my requirements. I will use your recommendation and filter the results

@kkarahainko
image
image
image
It seems that [Python] can be used, but I don't know how to use .Net to implement it

@luopinluobo technically it's possible, copy whole tensor to smaller one, like this

var output = new DenseTensor<float>(new[] { 1, 25200, 6 });

Parallel.For(0, 1, (a) =>
{
    Parallel.For(0, 25200, (b) =>
    {
        Parallel.For(0, 6, (c) =>
        {
            output[a, b, c] = original[a, b, c];
        });
    });
});

but I didn't see any difference + C# has no Tensor range and GPU acceleration operations, so I've decided not to implement this type of filtering for now, see no sense and didn't find elegant way.