AlexeyAB / darknet

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

Small object detection with Yolov4-CSP #7952

Open yusiyohpolimi opened 3 years ago

yusiyohpolimi commented 3 years ago

Hello there, thank you for very good work. I have images of 2048*1024 resolution. And I have an average width of 11 pixels for the labels. (The dataset is actually DriveU Traffic Light Dataset). I was reading your tips about training, and saw some changes for small objects in the cfg files. However they are for another version. What should I change in yolov4-csp.cfg for small object detection? In addition, I am also open to suggestions for a model for this task if anyone has. Thank you,

akashAD98 commented 3 years ago

@yusiyohpolimi check the readme file which has mentioned

for training for small objects (smaller than 16x16 after the image is resized to 416x416) - set layers = 23 instead of https://github.com/AlexeyAB/darknet/blob/6f718c257815a984253346bba8fb7aa756c55090/cfg/yolov4.cfg#L895

set stride=4 instead of https://github.com/AlexeyAB/darknet/blob/6f718c257815a984253346bba8fb7aa756c55090/cfg/yolov4.cfg#L892

set stride=4 instead of https://github.com/AlexeyAB/darknet/blob/6f718c257815a984253346bba8fb7aa756c55090/cfg/yolov4.cfg#L989

& also check this https://github.com/AlexeyAB/darknet/issues/7087#issuecomment-750924784

yusiyoh commented 3 years ago

Firstly thank you for your response. However, I have read already the part you sent, it is for yolov4 not yolov4-csp. I think there are structural differences. In addition, I cannot open the issue you sent in the end. Thanks again.

awaisbajwaml commented 3 years ago

@yusiyoh what is the difference between yolov4 vs yolov4-csp?

yusiyoh commented 3 years ago

Yolov4-CSP uses Cross-Stage-Partial (CSP) Network approach and is also known as Scaled-Yolov4. https://github.com/AlexeyAB/darknet/issues/7087

akashAD98 commented 3 years ago

@yusiyoh this is mentioned by alexyab

https://github.com/AlexeyAB/darknet/issues/7087

If you want to detect small objects using new models csp/x-mish, then its better to fine-tune yolov4x-mish.cfg/weights on COCO or your dataset by using Darknet with these modifications for each [yolo] layer in yolov4x-mish.cfg

objectness_smooth=0 scale_x_y = 1.05 remove iou_loss=ciou and iou_normalizer=0.07 as a last resort: remove new_coords=1 (and change activation=logistic to activation=linear in [convolutional] layers before [yolo] layers) Also if you want to detect objects in crowds, then train with iou_thresh=1.0 instead of iou_thresh=0.2

yusiyohpolimi commented 3 years ago

@yusiyoh this is mentioned by alexyab

7087

If you want to detect small objects using new models csp/x-mish, then its better to fine-tune yolov4x-mish.cfg/weights on COCO or your dataset by using Darknet with these modifications for each [yolo] layer in yolov4x-mish.cfg

objectness_smooth=0 scale_x_y = 1.05 remove iou_loss=ciou and iou_normalizer=0.07 as a last resort: remove new_coords=1 (and change activation=logistic to activation=linear in [convolutional] layers before [yolo] layers) Also if you want to detect objects in crowds, then train with iou_thresh=1.0 instead of iou_thresh=0.2

Do you know that I can use pytorch implementation and make these changes on cfg file instead of yaml (because they are not same configurations) and use that cfg file to train model with pytorch? Because It is mentioned that to use darknet and make these changes on cfg file.

vtyw commented 2 years ago

@yusiyohpolimi See here: https://github.com/AlexeyAB/darknet/issues/8081#issuecomment-931741303