AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.71k stars 7.96k forks source link

Novel EIoU Loss #7596

Open Dimfred opened 3 years ago

Dimfred commented 3 years ago

There has been a novel iou loss release here: Efficient IoU https://arxiv.org/abs/2101.08158

Tackles the problem of ciou that when two boxes have the same aspect ratio, but different width and height, i.e. bbox1 has wh = (2, 2) bbox2 has wh = (4, 4) aspect_ratio1 == aspect_ratio2 => no loss occurs from the aspect ratio penalty in CIoU

They are trying to directly optimize the discrepancy between w1 and w2 as well as h1 and h2. Additionally they introduce a focal part to that loss function.

eiou eiou2

Zzh-tju commented 3 years ago

I have read the paper and I have one doubt about the sec 3.1.3 “Limitations of Complete IOU Loss”. It is true that the aspect ratio loss term may lead to contradictory optimization, i.e., increasing the similarity of the aspect ratio, while keeping away form the ground truth label.

Actually, I noticed this phenomenon in June 2019. I have also conducted some experiments to explore the impact of this contradiction.

Add unit gradient. It means that we keep the step size of aspect ratio loss, and only use the unit gradient to determine the sign of the gradient. When w_pred < w_gt, we set the unit gradient of w to +1.0, otherwise we set to -1.0. This operation ensures that the updated gradient always approaches the GT direction.

On YOLOv3 and VOC 07+12, we got 48.8 AP (add unit gradient), while current CIoU loss produced 49.2 AP. This makes me think about whether it is necessary to keep the gradient approaching the GT direction all the time.

After that, I realize two potential reasons. 1) For some cases, even though the aspect ratio loss term produces contradictory gradient, it can still increase the IoU value. See the below examples, one can see that for the red box, h_pred does increase and keep away from h_gt. However, IoU value also increases (0.5→0.58). 2) As the name suggests, the aspect ratio loss term just focuses on increasing the similarity of the aspect ratio between predicted box and ground truth box. So we preserved its nature. 1111

1027663760 commented 1 year ago

@AlexeyAB Is darknet still updated