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

About "for training for small objects" #7437

Open jayer95 opened 3 years ago

jayer95 commented 3 years ago

@AlexeyAB

Regarding your description,

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

If I use yolov4x-mish.cfg or yolov4-tiny-3l.cfg to train and need to detect small objects, should I directly modify .cfg according to your instructions? Is there any formula for this modification?

stephanecharette commented 3 years ago

In case it helps -- especially for use with small objects -- also see this: https://www.ccoderun.ca/darkhelp/api/Tiling.html And this: https://www.ccoderun.ca/darkmark/ImageSize.html

jayer95 commented 3 years ago

@stephanecharette Thank you very much for providing such a good API. What I want to ask is, don’t .cfg need to make some changes? For example, those mentioned in my question.

I have some questions about your API. If the size of my original image is 1920x1080. I choose the size of the division to be 960x544, so that there will be 8 pixels overlaps in the middle. If the b-boxes is just above the overlap range, will the overlapped part be accurately synthesized when a complete image is synthesized at the end?

In this way, a picture is divided into four images. Does it need to infer 4 times? Will it cause more loading?

stephanecharette commented 3 years ago

Please also see this one: https://www.youtube.com/watch?v=Dp303GuxjFs

And yes, if you tile an image using 2x2 tiles, and each image takes 3 milliseconds to run inference, then it means it will now take you ~12 milliseconds total since you are running it 4 times.

And no, it doesn't require any changes to the .cfg file.

rafaelbate commented 3 years ago

In case it helps -- especially for use with small objects -- also see this: https://www.ccoderun.ca/darkhelp/api/Tiling.html And this: https://www.ccoderun.ca/darkmark/ImageSize.html

Hello @stephanecharette, thank you very much for that information, the image tilling really makes sense!

I need to detect very (really really) small objects. In am image of 3024x4032, I need to detect objects with dimensions starting in ~124x98 all the way down to ~41x53. I've seen that yolov4-csp isn't good at all to detect such small objects.

Do you happen to know if there is a detector good for detecting such small objects? (Like some version of YOLO) (Inference time is not important in my use case, but detection quality really is)

Thanks in advance!

stephanecharette commented 3 years ago

In case it helps -- especially for use with small objects -- also see this: https://www.ccoderun.ca/darkhelp/api/Tiling.html And this: https://www.ccoderun.ca/darkmark/ImageSize.html

Do you happen to know if there is a detector good for detecting such small objects? (Like some version of YOLO) (Inference time is not important in my use case, but detection quality really is)

Yes...see the video I linked to above, and the other videos I post in my channel.

stephanecharette commented 3 years ago

An example of finding small objects (10x10 pixels) in images measuring 1920x1080: https://www.youtube.com/watch?v=mB9CQcdSzgA This was done using Darknet/DarkHelp and the tiling feature built into DarkHelp.

rafaelbate commented 3 years ago

An example of finding small objects (10x10 pixels) in images measuring 1920x1080: https://www.youtube.com/watch?v=mB9CQcdSzgA This was done using Darknet/DarkHelp and the tiling feature built into DarkHelp.

Thanks for the help @stephanecharette, I've spent the last hours watching your videos and reading documentation, you've done such an amazing work and contribution for the community, thanks for that man!

I'm just wondering what would be the best configuration file for my use case (small objects). Now that YOLOv4-P6 is available, I think that would be the best cfg file I could use? Any thoughts on this matter?

stephanecharette commented 3 years ago

I'm just wondering what would be the best configuration file for my use case (small objects). Now that YOLOv4-P6 is available, I think that would be the best cfg file I could use? Any thoughts on this matter?

See: https://www.ccoderun.ca/programming/darknet_faq/#configuration_template

vtyw commented 2 years ago

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

jayer95 commented 2 years ago

@vtyw Thanks!