eric612 / MobileNet-YOLO

A caffe implementation of MobileNet-YOLO detection network
Other
865 stars 442 forks source link

Why we need another loop to compute the rest anchor matches? #258

Open troyliu0105 opened 4 years ago

troyliu0105 commented 4 years ago

Hi, Eric. Thx for your amazing job. But I have a little issue about the code...

https://github.com/eric612/MobileNet-YOLO/blob/6a4db28c7415b2c3bd52d51a7bfb366f5ebbe29b/src/caffe/layers/yolov3_layer.cpp#L647-L678

In line 674, we find the anchor which match the GT best, we treat it as positive sample and compute its gradient.

https://github.com/eric612/MobileNet-YOLO/blob/6a4db28c7415b2c3bd52d51a7bfb366f5ebbe29b/src/caffe/layers/yolov3_layer.cpp#L680-L698 But in line 680, we iterate the rest anchor, the anchor, which iou between GT is larger than iouthresh, is also positive sample.

So, here is my confusion, why don't we just iterate all the anchor one time, compute gradient for which iou is larger than threshold.

eric612 commented 4 years ago

This is a trick to increase mAP , which be used in alexeyAB project , but I think it may produce some false bbox in real case .

The first phase was original implement with yolov3 , it only do regression in one anchor which is the best iou , and second phase will search the anchor pool , and find another anchors can also do the same thing except the first phase anchor (accumulate delta), if the size of GT box was in middle of two anchors (or more) , it was helpful , especially in small objects , take more chance to detect

troyliu0105 commented 4 years ago

Thanks for reply, I figured it out with your help. I think the main point is to increase the positive samples.

In the original implementation. If there is a image with N gt boxes and there are only 3 * N anchors (every loss layer must have one anchor to match the GTs).

With alexeyAB implementation, the extra anchors (match GT enough) are added.

But I noticed that alexeyAB's impl accumulate also the MSE gradients and yours do not. Is there anything reason?

https://github.com/AlexeyAB/darknet/blob/e6469eb071521a4ff5be8c0e9cceb524d0a65a95/src/yolo_layer.c#L181-L184

eric612 commented 4 years ago

Yes , I usually use GIOU here , I forgot to check MSE term .