AlexeyAB / darknet

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

Custom data set training, random=0 or 1 #2326

Open Sauraus opened 5 years ago

Sauraus commented 5 years ago

If I know that my images & objects will all be of a certain fixed size, can I forgo random=1? and instead use random=0?

Also in your readme you say to change random in 1 layer only, is that correct? Should random not be 1 or 0 in all layers?

set flag random=1 in your .cfg-file - it will increase precision by training Yolo for different resolutions: link

TheonSoong commented 5 years ago

same question.

hhaiyue commented 5 years ago

same question. @AlexeyAB

AlexeyAB commented 5 years ago

@Sauraus @theonsoong @hhaiyue Hi,

If you use the same size of Training/Validation/Test images and videos, then you can train with random=0

Sauraus commented 5 years ago

@Sauraus @theonsoong @hhaiyue Hi,

If you use the same size of Training/Validation/Test images and videos, then you can train with random=0

The Yolo V3 config file has 3 lines with random=1 do we modify each one of those or only the last?

AlexeyAB commented 5 years ago

@Sauraus Only in the last layer [yolo].

dreambit commented 5 years ago

@AlexeyAB Hi, i am still confused about random=1;

I going to train network with new yolo_v3_spp_pan.cfg to compare results with previously trained network with yolo_v3_spp.cfg. Network size is 416x255 (and i am not going to change it after training, so size will be the same during training and inference) and most of the image are 1280x784, 720x576.

Is it right that when we use random=1, we can train network lets say at 416x416 and use it as 544x544 as well?

Increase network-resolution by set in your .cfg-file (height=608 and width=608) or (height=832 and width=832) or (any value multiple of 32) - this increases the precision and makes it possible to detect small objects: link

it is not necessary to train the network again, just use .weights-file already trained for 416x416 resolution but to get even greater accuracy you should train with higher resolution 608x608 or 832x832, note: if error Out of memory occurs then in .cfg-file you should increase subdivisions=16, 32 or 64

So can i set random=0 and expect the same accuracy?

I also noticed that when i resize image from 1280x784 to 416x255 and send it for detection results are slightly different from those i send at 1280x784. I thought darknet does the same, resizes image to fit it to network. why this is happening? maybe because different resize algorithm?

Thanks

AlexeyAB commented 5 years ago

@dreambit

So can i set random=0 and expect the same accuracy?

random=1 can improve mAP even if you try to detect with the same resolution, but you should train longer.


I going to train network with new yolo_v3_spp_pan.cfg to compare results with previously trained network with yolo_v3_spp.cfg.

Did you train yolo_v3_spp.cfg with random=1?

random=1 can be used for two things:


maybe because different resize algorithm?

I think - yes. Different resizing algorithms affect on final result.

dreambit commented 5 years ago

@AlexeyAB

Did you train yolo_v3_spp.cfg with random=1?

Yes. But with yolo_v3_spp_pan.cfg i would like to set random=0 in order to speed up training. I think it may be 2x-3x times faster right?

Different resizing algorithms affect on final result.

Could you explain which one is used in darknet impl?

INTER_NEAREST - a nearest-neighbor interpolation
INTER_LINEAR - a bilinear interpolation (used by default)
INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

Thank you!

AlexeyAB commented 5 years ago

@dreambit

There is used INTER_LINEAR interpolation in the Darknet:

I think it may be 2x-3x times faster right?

Yes, since you can use lower subdivisions that speedup training.

dreambit commented 5 years ago

@AlexeyAB Thanks for your help 👍 .