THU-MIG / yolov10

YOLOv10: Real-Time End-to-End Object Detection
https://arxiv.org/abs/2405.14458
GNU Affero General Public License v3.0
8.17k stars 691 forks source link

Redundant detection boxes without NMS #236

Open wuhanshuo opened 1 month ago

wuhanshuo commented 1 month ago

My code:

from ultralytics import YOLOv10

model = YOLOv10("weights/trained_v10m.pt")
video_path = "my/video/path"

results = model(source=video_path, conf=0.25, device=[0], save=False, show=False, stream=True)
for idx, result in enumerate(results):
    dets = result.boxes.data.cpu().numpy() # --> Matrix (x, y, x, y, conf, cls)
    print("dets:", dets)

Outputs in frame 266:

video 1/1 (frame 266/7397) /cluster/my/path/video.mp4: 384x640 3 wheels, 1 car, 1 minivan, 10.3ms
dets: [[     1212.2      309.88      1464.7      482.17     0.98511           2]
 [     1290.3      425.93      1318.7      480.26     0.95292           0]
 [     721.58       360.8      767.41      394.72     0.93868           1]
 [     1213.4      413.81        1234      461.19     0.50953           0]
 [     1213.1       412.4      1236.8      460.92     0.29856           0]]

The last two boxes are almost the same one but detected twice. Why does YOLOv10 have this issue by replacing NMS with consistent dual assignments?

lryan599 commented 3 weeks ago

I also have the same problem. Especially set the confidence threshold to a small value, as mentioned in #136 , 0.05. Is there any way to solve it?

jameslahm commented 2 weeks ago

Thanks for your interest! Do you use the finetuned model to perform predictions? Could you please try to train the model for more epochs? Thanks!

wuhanshuo commented 2 weeks ago

Thanks for your interest! Do you use the finetuned model to perform predictions? Could you please try to train the model for more epochs? Thanks!

@jameslahm Many thanks for your comments. I trained the model on my dataset starting from your pretrained weights. No matter how I change epochs from 900~2000 and other training parameters, all models keep giving redundant detection boxes.

One of trainings: image

I also submit a issue here. Now the problem is solved by adding an NMS as prediction post-process...

jameslahm commented 2 weeks ago

@wuhanshuo Thanks! What if you set a higher confidence threshold than that of the redundant prediction with the lower score?

lryan599 commented 2 weeks ago

@wuhanshuo Thanks! What if you set a higher confidence threshold than that of the redundant prediction with the lower score?

But I think it is hard to set an appropriate confidence threshold...

After all it is unpredictable...

wuhanshuo commented 2 weeks ago

@wuhanshuo Thanks! What if you set a higher confidence threshold than that of the redundant prediction with the lower score?

@jameslahm Yes I believe a higher confidence will remove redundant boxes significantly. However I will not consider it as the first option, since in my task a higher confidence may miss some small objects...

I agree with @lryan599, it is unpredictable and may harm the generalization ability of the model in difference scenes... Also it is hard to find a perfect confidence.

@lryan599 I would suggest the solution here. In my task, adding an NMS has no significant impact on runtime.

jameslahm commented 2 weeks ago

@wuhanshuo Thanks! Would you mind sharing your example, including the checkpoint and the detected image with us? We will also try to find other solutions.

lryan599 commented 2 weeks ago

@wuhanshuo Thank you for your suggestion! I will give it a try. @jameslahm Maybe you can add NMS as an optional argument? After all, in a single prediction, there are only a few duplicate detection boxes, so the NMS will not take too much time, I think. This is for engineering considerations.

jameslahm commented 2 weeks ago

@lryan599 Thanks for your suggestion! That is a good solution and we will consider this.

wuhanshuo commented 2 weeks ago

@wuhanshuo Thanks! Would you mind sharing your example, including the checkpoint and the detected image with us? We will also try to find other solutions.

@jameslahm Due to project confidentiality reasons, I cannot post my data here. I have sent an email to your gmail address with my checkpoint and an example image. Many thanks for your reply.

jameslahm commented 2 weeks ago

@wuhanshuo Thanks a lot! We have received your email.