AlexeyAB / darknet

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

Letter_box flag for anchor calculation! #7977

Open NikitaBezukhov opened 3 years ago

NikitaBezukhov commented 3 years ago

@AlexeyAB It looks like -letter_box flag doesnt work for anchor calculation, so when you have images with different aspect ratios in training dataset, they all get stretched differently during resize (lets say to 640x640 in my case) and calculated anchors are bad. So I had to manually pad all pics and bboxes to square with Albumentations, and then I got good anchors calculated and model performance improved by 2.45% mAP! And also it looks like someone who trains model with letter box will suffer If he calculated anchors without letter boxing. You should ether calculate anchors without letter box and train/infer without letter box (if aspect ratios on train/inference are the same), or calculate anchors with letter box (which it looks like not implemented yet in this repo) and train/infer with letter box.

lsd1994 commented 3 years ago

What dataset do you use for vaild map?It shouldn't have such a huge difference.

NikitaBezukhov commented 3 years ago

What dataset do you use for vaild map?It shouldn't have such a huge difference.

It does, because all the pics in my dataset have different aspect ratios.