AlexeyAB / darknet

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

anchors in tiny_yolo2 #838

Open 123liluky opened 6 years ago

123liluky commented 6 years ago

1、I use 5 anchors for detection in the beginning, the last convolutional and region is: [convolutional] size=1 stride=1 pad=1 filters=35 activation=linear

[region] anchors = 0.7,0.97, 2.22,3.58, 4.31,9.25, 6.12,4.15, 10.8,8.55 bias_match=1 classes=2 coords=4 num=5 softmax=1 jitter=.2 rescore=1

object_scale=5 noobject_scale=1 class_scale=1 coord_scale=1

absolute=1 thresh = .6 random=0 2、 Then, I try using only one anchor for detection like below: [convolutional] size=1 stride=1 pad=1 filters=7 activation=linear

[region] anchors = 3.09,2.72 bias_match=1 classes=2 coords=4 num=1 softmax=1 jitter=.2 rescore=1

object_scale=5 noobject_scale=1 class_scale=1 coord_scale=1

absolute=1 thresh = .6 random=0

I find detection results in both 1 and 2 are ok. Both squares and rectangles with different size are detected with high probability. Does it mean anchors amounts and values are not vital for detection in my application? Thank you.

AlexeyAB commented 6 years ago
123liluky commented 6 years ago

1、map for one anchor cfg: 1anchor map for five anchors cfg: 5anchors They are nearly the same. 2、detected examples for one anchor cfg: 20 27 and detected examples for five anchors cfg: 20 27 I am confused why results of one anchor cfg are also satisfying? I trained the two networks both without pretrained parameters.

AlexeyAB commented 6 years ago

Does it mean anchors amounts and values are not vital for detection in my application?

Yes.

  1. Mybe it is because the vein is always rectangular, and the artery is always square.

  2. Also because all images (in training and validation dataset) has the same size and the same aspect ratio. So it doesn't require different anchors.

  3. And because you use relaxed data augmentation (jitter=0.2 random=0), so this model can detect well objects only on the images with the same size and the same aspect ratio.


Also you can try to train yolov3-tiny.cfg (5.5 Gflops) instead of yolov2-tiny-voc.cfg (6.9 Gflops), and compare mAP.

Train using command: ./darknet detector train data/obj.data yolov3-tiny_obj.cfg yolov3.conv.105

File yolov3.conv.105 you can get by using command: https://github.com/AlexeyAB/darknet/blob/24f563ce7165c2c44486fe8d0a2caea8d7c5a887/build/darknet/x64/partial.cmd#L21