AlexeyAB / darknet

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

anchors in yolov4-tiny.cfg #6107

Open tuteming opened 4 years ago

tuteming commented 4 years ago

in yolov4-tiny.cfg, there are mask = 3,4,5 and mask = 1,2,3 common anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 why 6 anchors? is not 5 anchors? if darknet.exe detector calc_anchors data/obj.data -num_of_clusters 6 -width 416 -height 416 what common anchors for mask = 3,4,5 , what for mask = 1,2,3? thanks.

HaolyShiit commented 4 years ago

https://github.com/AlexeyAB/darknet/issues/6067#issuecomment-650180365

tuteming commented 4 years ago

I see, but no answer.

fsaxen commented 4 years ago

I think you are correct. mask should be 0,1,2 and 3,4,5 instead of 1,2,3 and 3,4,5. The first anchor will never be used and the third in both yolo layers. See yolov4.cfg for reference.

scamianbas commented 4 years ago

I agree with @fsaxen , in yolov3-tiny.cfg masks are 0,1,2 and 3,4,5. Why this should be different in yolov4-tiny.cfg ?

alexanderfrey commented 4 years ago

Anchors are definitely wrong. Correcting mask from 1,2,3 in second yolo layer to 0,1,2 improved map +25%

@AlexeyAB

AlexeyAB commented 4 years ago

Anchors are definitely wrong. Correcting mask from 1,2,3 in second yolo layer to 0,1,2 improved map +25%

What dataset do you use? Show mAP results for both cases.

geminikq commented 4 years ago

I believe @alexanderfrey is right. I used my own data (only has one class) to train by using 1,2,3 set and 0,1,2 set, the 0,1,2 version is much better than the other. Then I tested the same dataset by using yolov3-tiny, and yolov3-tiny is also much better than 1,2,3 version.

not-matthias commented 4 years ago

I reproduced similar results. I trained my model with 30k iterations and had about 80% mAP. I changed the mask from 1, 2, 3 to 0, 1, 2 and trained the model with the same data and just used the weights from my previous training. I received a mAP of 97.45% after 2k iterations.

Great find!

not-matthias commented 4 years ago

WARNING: If you want to use the config and weights with OpenCV 4.4, you need to use 1, 2, 3 and not 0, 1, 2 for the mask otherwise an assertion will fail.

lsd1994 commented 3 years ago

I reproduced similar results. I trained my model with 30k iterations and had about 80% mAP. I changed the mask from 1, 2, 3 to 0, 1, 2 and trained the model with the same data and just used the weights from my previous training. I received a mAP of 97.45% after 2k iterations.

@not-matthias Hi, you mean you got +17%mAP when change anchor index from 1,2,3 to 0,1,2. Are there many small objects in your dataset?