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

single class training with tiny-yolov3 #3278

Open gongjing1996 opened 5 years ago

gongjing1996 commented 5 years ago

Hello, I want to train tiny-yolov3 to detect a single class. I have 8862 images for training, 1366 images for validation. All the images are gray images and the image resolution is 640×512. First time I train tiny-yolov3 with the following cfg: batch=64 subdivisions=16 width=640 height=512 channels=3 ... max_batches = 50020 policy=steps steps=40000,45000

And I get the mAP around 75%, avg loss larger than 1.3. Now I want to improve the object detection,so I recalculate anchors for my dataset with -width 640 -height 512, 6 anchors with IOU 69.19%: 17, 17, 34, 31, 60, 45, 80, 80, 134, 95, 179,167 9 anchors with IOU 73.42%: 15, 16, 27, 23, 33, 39, 55, 35, 64, 56, 100, 71, 66,124, 146,106, 185,178 The questions I want to ask are:

  1. What number of max_batches should I set? You have said that usually sufficient 2000 iterations for each class(object), but not less than 4000 iterations in total. So I think maybe I should use a smaller max_batches.

  2. How many anchors should I choose? And how should I modify the mask(in cfg)?

  3. If I want to expand the single channel image into three channels, one channel is the origin image,anothers are the images with intensity inversion or histogram normalization. Maybe this is like 'concatanate'. Is this feasible?

  4. If I have changed the cfg file, such as add some conv layers after the seventh layer,but the first 7 layers remained the same. Should I use the partial commad to extract yolov3-tiny.conv.7 to train?

AlexeyAB commented 5 years ago

@gongjing1996 Hi,

  1. Use 2000 iterations for each class(object), how many classes do you have?

  2. Try to use 9 anchors and set masks as described - so that 1st-[yolo]-layer has anchors larger than 60x60, 2nd larger than 30x30, 3rd remaining: https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

But you should change indexes of anchors masks= for each [yolo]-layer, so that 1st-[yolo]-layer has anchors larger than 60x60, 2nd larger than 30x30, 3rd remaining. Also you should change the filters=(classes + 5)* before each [yolo]-layer. If many of the calculated anchors do not fit under the appropriate layers - then just try using all the default anchors.

  1. If you can do it by yourself - then you can do it and change such 3-channels images for Training Yolo, just set channels=3 in cfg-file.

Otherwise if you trained by using 1-channel images, then set channels=1 in cfg-file.

  1. Yes.
gongjing1996 commented 5 years ago

@AlexeyAB Thank you very much!

  1. one class, 8862 images for training, 1366 images for validation, all are thermal images.
  2. I'm still confused to how to set masks of anchors. If I use 9 anchors, the anchors of first yolo layer are : 33, 39, 55, 35, 64, 56, 100, 71, 66,124, 146,106, 185,178 ? But the remaining anchors are smaller than 30x30? I don't understand this, could you give me an example please?