AlexeyAB / darknet

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

Anchors - Change amount #1507

Closed VisionEp1 closed 6 years ago

VisionEp1 commented 6 years ago

Hi,

  1. is increasing the amount of anchors to 12 ot 15 a good idea to increase accuracy?

If so what else do i need to change ? (filters?)

  1. Shall the -width and -height value of the calc_anchors command always equal the network size while training? Or is it better to use a slighlty lower or higher number.

Thanks in advance

AlexeyAB commented 6 years ago

@VisionEp1 Hi,

  1. Yes, it is a good idea for some cases. Yes, you should change filters: https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

(Generally filters depends on the classes, coords and number of masks, i.e. filters=(classes + coords + 1)*<number of mask>, where mask is indices of anchors. If mask is absence, then filters=(classes + coords + 1)*num)

  1. Always should be equal to the network size.
VisionEp1 commented 6 years ago

Thanks. so would i change

[yolo]
mask = 3,4,5
anchors = 60.3971,60.2603, 120.2582,115.1511, 152.4153,212.0303, 245.7963,136.5225, 192.5882,333.4015, 289.9000,247.2551, 468.5411,191.2643, 208.4178,509.1076, 367.7727,373.1860, 545.8881,343.7682, 378.0593,544.8827, 556.4221,544.0161
classes=3
num=12
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
focal_loss =1
  1. Should i add "mask=12" instad of changing num?
  2. I thought filters is (classes +5 )* 3. So to what number should i change filters? (what is the value of coords in your formular)
VisionEp1 commented 6 years ago

ps:

  1. i added focal_loss for better stability sicne my objects within one class differ a lot. Is that a good idea?

Thanks like always!

AlexeyAB commented 6 years ago
  1. num=12 and distribute masks= uniform across all yolo-layers, 4 in each of 3 yolo-layers in the yolov3.cfg

  2. filter=(classes+5)*4

  3. Just test it.

VisionEp1 commented 6 years ago

thanks!