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

Detector - added iou_thresh=0.213 parameter to use more than 1 anchor per truth #4451

Closed
AlexeyAB opened this issue Dec 4, 2019 · 6 comments

Comments

@AlexeyAB
Copy link
Owner

AlexeyAB commented Dec 4, 2019

Now you can use

[yolo]
iou_thresh=0.213

So will be used more than 1 anchors per object (truth), not only the best anchor but also all anchors with IoU > 0.213

Related to: #3114 (comment)

Commits:

@AlexeyAB
Copy link
Owner Author

AlexeyAB commented Dec 4, 2019

@glenn-jocher Hi,

What mAP gain did you get by using each of your improvements?

  1. iou_thresh=0.213 (more than 1 anchor per truth) - current issue Detector - added iou_thresh=0.213 parameter to use more than 1 anchor per truth #4451
  2. Mosaic data augmentation - Detector - Mosaic data augmentation  #4264
  3. [yolo] iou_normalizer=0.07 cls_normalizer=1.0 iou_loss=giou (iou 3.31, cls 42.4, obj 52.0) Test models with good hyperparameters - +4.8% mAP@0.5 on MS COCO test-dev #4430

@LukeAI
Copy link

LukeAI commented Dec 6, 2019

This gave me over 1mAP boost

CSresnext50-spp-pan-scale
csresnextleaky

CSresnext50-spp-pan-scale-iou
chart

@AlexeyAB
Copy link
Owner Author

AlexeyAB commented Dec 6, 2019

@LukeAI

Also try: [yolo] iou_normalizer=0.07 cls_normalizer=1.0 iou_loss=giou (iou 3.31, cls 42.4, obj 52.0)

@glenn-jocher
Copy link

glenn-jocher commented Dec 6, 2019

@glenn-jocher Hi,

What mAP gain did you get by using each of your improvements?

  1. iou_thresh=0.213 (more than 1 anchor per truth) - current issue Detector - added iou_thresh=0.213 parameter to use more than 1 anchor per truth #4451
  2. Mosaic data augmentation - Detector - Mosaic data augmentation  #4264
  3. [yolo] iou_normalizer=0.07 cls_normalizer=1.0 iou_loss=giou (iou 3.31, cls 42.4, obj 52.0) Test models with good hyperparameters - +4.8% mAP@0.5 on MS COCO test-dev #4430

@AlexeyAB Unfortunately I don't have exact ablation test results to give you. The iou_thresh, if set to 0.0, will return very poor mAPs, because every anchor is trying to fit every target. Mosaic was extremely important for preventing overfitting during training, which allows us to train longer (i.e. to 500k iterations) and increase mAP. It's also very important to plot each of your loss components seperately, as in the past I've seen that objectness loss (and cls loss to a lesser degree) are much more prone to overfitting than GIoU loss. I've actually never seen GIoU loss overfit.

The normalization part seems to be integrally important to every multi-loss neural network, with a good rule of thumb being that multicomponent losses (like we use in object detection) should contribute proportionally to their importance to the metric (mAP). Hyperparameter evolution is an effective but extremely slow way to do this. I'm thinking a good shortcut might be to train for one epoch with default normalizers in place, then update the 3 normalizers (box, obj, cls) to bring all of the losses back into balance, targeting a median value of say 5 each at the end of the first epoch. Logic like this might help the community in general train more effective models more easily, as I've noticed that COCO hyperparameters are not always optimal on 3rd party datasets.

@AlexeyAB
Copy link
Owner Author

AlexeyAB commented Dec 6, 2019

@glenn-jocher
Do you mean that we should try to update the 3 normalizers (box, obj, cls) for each epoch, so each of 3 losses will be equal?

I added such ToDo. #4463

@glenn-jocher
Copy link

@AlexeyAB you know I tried that once, but it didn't work very well. Maybe they should naturally diverge as training progresses, not sure.

In any case probably balancing them once before actual training begins is probably a good place to start, or maybe balancing them after just the first or second epochs maybe.

@cenit cenit closed this as completed Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants