label-studio-ml-backend icon indicating copy to clipboard operation
label-studio-ml-backend copied to clipboard

YOLO backend Max number of detection 300. Can we config via docker arg?

Open robert-stevenson-1 opened this issue 1 month ago • 4 comments

I wanted to use my own YOLO models for auto-labelling my images, but they only label up to 300 instances. After some digging, I found this is due to a limit in Ultralytic's .predict() function.

I solved my case by just changing results = self.model.predict(path) to results = self.model.predict(path, max_det=3000) in control_models/rectangle_labels.py under the predict_regions function.

Can it be configured in the Docker Compose file to make it easier to change? I might end up doing it at some point myself, but it may be a while before I get around to these changes, so I thought someone else might be able to get to them before me.

robert-stevenson-1 avatar Nov 26 '25 14:11 robert-stevenson-1

What does the max_det param do?

makseq avatar Nov 26 '25 18:11 makseq

It limits how many detected objects are returned from the predict method.

300 is the default, hence why you would get no more than 300 annotations return from the auto annotations feature.

Increase it means that the labelling model can return more annotations for you when using the auto annotations feature.

I should also state that I've only tried with bounding box labelling and models, as that was my use case when trying to label images with many more than 300 instances of objects

robert-stevenson-1 avatar Nov 26 '25 18:11 robert-stevenson-1

I think it makes more sense if we add a new model parameter like model_score_threshold:

<RectangleLabels name="label" toName="image" model_score_threshold="0.25" model_max_det="500" opacity="0.1">

It would be great if you could contribute it. The fix can look like this: https://github.com/HumanSignal/label-studio-ml-backend/pull/838/files

makseq avatar Nov 27 '25 00:11 makseq

I would agree. That does seem to make more sense.

I'll look into implementing it once I get a little bit of time to go through it

robert-stevenson-1 avatar Nov 27 '25 07:11 robert-stevenson-1