Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant detection boxes without NMS #236

Open
wuhanshuo opened this issue Jun 10, 2024 · 11 comments
Open

Redundant detection boxes without NMS #236

wuhanshuo opened this issue Jun 10, 2024 · 11 comments
Assignees

Comments

@wuhanshuo
Copy link

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?

@wuhanshuo wuhanshuo changed the title Redundant detected boxes Redundant detection boxes with one2one Jun 13, 2024
@wuhanshuo wuhanshuo changed the title Redundant detection boxes with one2one Redundant detection boxes without NMS Jun 14, 2024
@lryan599
Copy link

lryan599 commented Jun 19, 2024

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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

@lryan599
Copy link

@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
Copy link
Author

wuhanshuo commented Jun 23, 2024

@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
Copy link
Collaborator

@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
Copy link

@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
Copy link
Collaborator

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

@wuhanshuo
Copy link
Author

wuhanshuo commented Jun 23, 2024

@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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants