AlexeyAB/darknet

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

AlexeyAB opened this issue ยท 6 comments

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:

@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 #4451
  2. 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) #4430

This gave me over 1mAP boost

CSresnext50-spp-pan-scale
csresnextleaky

CSresnext50-spp-pan-scale-iou
chart

@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 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 #4451
  2. 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) #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.

@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

@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.