AlexeyAB / darknet

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

Error in anchor calculation (YOLOV3-TINY) #5470

Open rushipatel7 opened 4 years ago

rushipatel7 commented 4 years ago

I am training a model for 36 classes (characters and digits). Each class has around 10000 images (size 75x100). Here's a sample of my training data data sample

I am following this repo since training is to be done on Google Colab I tried generating anchors but am getting the following error. error

I am new to CV and Yolo so i am still learning stuff. Am I doing something wrong? Is this happening becuse of wrong labelling? (I am labelling the whole image) Here is my labelling format 13 0.506667 0.500000 0.986667 0.980000

AlexeyAB commented 4 years ago

https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

Only if you are an expert in neural detection networks - recalculate anchors for your dataset for width and height from cfg-file: darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416 then set the same 9 anchors in each of 3 [yolo]-layers in your cfg-file. 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.

rushipatel7 commented 4 years ago

@AlexeyAB yes i have started training with default anchors, will share the results.

rushipatel7 commented 4 years ago

hello @AlexeyAB, I trained the data for about 5000 iterations and tried to check whether training is going properly or not but whenever i try to load the weights and cfg i get the following error:

yolo error (Used opencv's dnn package to load the weights and cfg) net = cv2.dnn.readNetFromDarknet("path/to/cfg/yolov3-tiny-obj.cfg", "path/to/weights/yolov3-tiny-obj_2000.weights") Here is the config file: yolov3-tiny-obj-cfg.txt I looked into this issue but can't seem to find a solution. Is it happening because my input images are too small (75x100) and the default network resolution is 416x416?

Also i was unable to calculate map since my collab runtime crashed after every 1000th iteration.