AlexeyAB / darknet

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

yolov4-tiny_3l (3 layers) to improve detection for small objects? #6155

Open spinlud opened 4 years ago

spinlud commented 4 years ago

Is it possible to have an example of yolov4-tiny with 3 layers to improve detection for small objects?

yolov3-tiny_3l

image

spinlud commented 4 years ago

Thanks @dadaligoudan, will give it a try! The formula filters=(classes + 5) x 3 in the [convolutional] before each [yolo] layer still applies?

dadaligoudan commented 4 years ago

Thanks @dadaligoudan, will give it a try! The formula filters=(classes + 5) x 3 in the [convolutional] before each [yolo] layer still applies?

Yes, the formula still applies. Sorry for deleting the cfg file temporarily, I will test this cfg file within two days and see how it works. If it works fine, I will publish the cfg file and the trainning result here.

dadaligoudan commented 4 years ago

yolov4-tiny-3l.zip Hi, @spinlud I have tested this cfg file, The MAP trained on my small-person-and-car data is 0.46 and it is still going up. The MAP of yolov4-tiny.cfg model I trained on my data is 0.365. I have tested the performance of this cfg file on my data and it performs better than yolov4-tiny. Maybe it works fine for your data of small objects too!

spinlud commented 4 years ago

@dadaligoudan Thank you! I am training right now with your version, let's see how it goes 😎

marcusbrito commented 4 years ago

@dadaligoudan Should we use the same pretrained .weights file(from the original yolov4-tiny trained n COCO) with this new config?

How does it compare with the original yolov4-tiny in terms of speed?

sealedtx commented 4 years ago

Training my custom dataset on a single object with yolov4-tiny-3l decrease my mAP@0.5 by ~0.1% compared to yolov4-tiny, and decrease mAP@0.5-0.9 by ~2%. I think it performs worse because the number of small objects in my dataset is less than number of big objects, but still strange

laclouis5 commented 4 years ago

I also trained this network on my database (1200 images), it does not have particularly very small objects but old Yolo v3 Tiny 3L improved the AP50 an AP compared to Yolo v3 Tiny and I expected same improvement with Yolo v4 Tiny 3L but the result is mitigated : AP decreased by almost 2 but AP50 increase about almost 1%.

spinlud commented 4 years ago

I've obtained pretty much the same accuracy on my dataset, about 25k images. I am testing now higher resolutions for the yolov4-tiny

laclouis5 commented 4 years ago

Ok, I also tested different resolutions for Yolo v4 Tiny : 416, 544 and 632. A better resolution increased AP50 but decreased AP (632 resolution). The optimum is 544 for my database.

Resolution AP AP50
416 41.06 % 85.72 %
544 46.74 % 88.76 %
632 42.45 % 88.89 %
dadaligoudan commented 4 years ago

It makes me confused too. The map should not be smaller, if not bigger than the yolov4-tiny. The yolov4-tiny-3l combines the feature map of the former layer and produces the output 7676, 3838, 1919 instead of 3838, 1919 if the input of the network is 608608. In principle, it will fit the small objects better. The yolov3-tiny-3l did the same way... I am not sure if it is something wrong with the yolov4-tiny-3l.cfg, but i do have higher map compared with yolov4-tiny. My database is full of small objects which size is less than 15*15 pixels, maybe that is the reason. I changed the anchors based on my database and i think adding more small anchors based on my database helps. I am sorry for troubling you and maybe in recent days AlexeyAB will publish a official yolov4-tiny-3l.cfg file...

laclouis5 commented 4 years ago

Sure, maybe Yolo V4 Tiny 3L implementation is wrong.

Did you try Yolo v4 Tiny with changing anchors to better fit your small objects?

dadaligoudan commented 4 years ago

Sure, maybe Yolo V4 Tiny 3L implementation is wrong.

Did you try Yolo v4 Tiny with changing anchors to better fit your small objects?

I use K-means method to get the anchors for my database cause the anchors of coco dataset seems too big for my database and it will cause infinite loss.

AlexeyAB commented 4 years ago

I added these models: https://github.com/AlexeyAB/darknet/commit/de68e19cc627f642023f09513ac2306fbcbc1e4b

stephanecharette commented 3 years ago

@AlexeyAB Are there MSCOCO pre-trained weights available for yolov4-tiny-3l? Someone was asking on the discord today. I don't see a link to it in the readme.

AlexeyAB commented 3 years ago

@stephanecharette You can use the same COCO pre-trained weights https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.conv.29 for both yolov4-tiny.cfg and yolov4-tiny-3l.cfg

Micky-123 commented 3 years ago

@AlexeyAB @stephanecharette : This weight yolov4-tiny.conv.29 file is ~19MB whereas yolov4-tiny weight file is ~23MB. I was guessing that the file size of yolov4-tiny-3l should be more than yolov4-tiny. Isn't it the case?

AlexeyAB commented 3 years ago

@Micky-123 They use different Neck/Head, while they use the same backbone, and weights-file yolov4-tiny.conv.29 is for backbone.

Micky-123 commented 3 years ago

@AlexeyAB : Do I need to add some more weights to yolov4-tiny.conv.29 to make it work with yolov4-tiny-3l.cfg? there should be some weights related to neck/head as well or there are none?

Micky-123 commented 3 years ago

@AlexeyAB : can you please help throw some light on the above question...

AlexeyAB commented 3 years ago

@Micky-123

Do I need to add some more weights to yolov4-tiny.conv.29 to make it work with yolov4-tiny-3l.cfg? there should be some weights related to neck/head as well or there are none?

No, you don't need neck / head weights because they are more class-specific. Just use yolov4-tiny.conv.29 file.

Micky-123 commented 3 years ago

@Micky-123

Do I need to add some more weights to yolov4-tiny.conv.29 to make it work with yolov4-tiny-3l.cfg? there should be some weights related to neck/head as well or there are none?

No, you don't need neck / head weights because they are more class-specific. Just use yolov4-tiny.conv.29 file.

Thanks @AlexeyAB . Will try it out.