Open May-forever opened 4 years ago
Just set in cfg-file:
[net]
mixup=1
How to see the changes in training images and save them?
Use flag -show_imgs
at the end of training command
./darknet detector train ... -show_imgs
it will show and save augmented images near with executable file
if you don't want to show them (just for saving jpg files) use:
./darknet detector train ... -show_imgs -dont_show
For Classifier there are:
For Detector there are:
Just set in cfg-file:
[net] mixup=1
How to see the changes in training images and save them?
Use flag
-show_imgs
at the end of training command./darknet detector train ... -show_imgs
it will show and save augmented images near with executable fileif you don't want to show them (just for saving jpg files) use:
./darknet detector train ... -show_imgs -dont_show
For Classifier there are:
- mixup=1 #3272
- cutmix=1 #4419
- mosaic=1 #4432
For Detector there are:
- mixup=1 #3272
- mosaic=1 #4264
Hi @AlexeyAB , thank you very much for your help.
Can't cutmix=1 be used to train a detector yet?
Looking forward to hearing from you, thanks a lot.
@AlexeyAB
Can I set mixup=1
and mosaic=1
together in yolov3.cfg
or Gaussian+CIoU+yolov3.cfg
to improve mAP?
[net]
batch=32
subdivisions=16
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
mixup=1
mosaic=1
@nyj-ocean
If you set both - then will be used only Mosaic
mixup=1
mosaic=1
Because in the most tests MixUp doesn't give any gain in AP during training Detector (MixUp gives boost of accuracy only for training Classifier with mixup=1, and then this pre-trained weights file with higher Top1 is used for training Detector with mixup=0 - so it gives higher ~+4 AP)
Mosaic should increase accuracy for both training Classifier and Detector.
So is recommended:
cutmix=1 mosaic=1
for training Classifiermosaic=1
for training Detector@AlexeyAB
If I only set mosaic=1
in yolov3.cfg
.
Then can I directly use the pre-weights darknet53.conv.74
to train mosaic+yolov3
?
Or should I train Classifier with mosaic=1 at first,and then this pre-trained weights file with higher Top1 is used for training Detector with mosaic=1?
Or should I train Classifier with mosaic=1 at first,and then this pre-trained weights file with higher Top1 is used for training Detector with mosaic=1?
Yes, you can. And it will increase accuracy. But for an even greater increase in accuracy, first train the Classifier with a mosaic and cutmix, and then the Detector with a mosaic.
@AlexeyAB
I try mosaic+yolov3
in the latest repo.
I only set mosaic=1
in yolov3.cfg
.Then I directly use my own dataset to train mosaic+yolov3
with the pre-weights darknet53.conv.74
.
It can train normally at the beginning ,but produce NAN later as following.
But I can train mixup+yolov3
normally,and it do not produce NAN
@nyj-ocean
@AlexeyAB
Can you attach your cfg-file? mosaic+yolov3.cfg.txt
Does training work well without mosaic=1? Yes,I can train yolov3 without mosaic=1 as shown in https://github.com/AlexeyAB/darknet/issues/4357#issuecomment-562425430
What dataset do you use? I use my own dataset. 1500 images for training set ,other 1500 images for val set.
Do you use GPU=1 CUDNN=1? Yes, I set the Makefile like following
GPU=1 CUDNN=1 CUDNN_HALF=1 OPENCV=1 AVX=0 OPENMP=0 LIBSO=0 ZED_CAMERA=0
@AlexeyAB
But I can train mixup+yolov3
normally,and it do not produce NAN as following
@AlexeyAB
mosaic+yolov3
produce Nan about 20k steps as shown in https://github.com/AlexeyAB/darknet/issues/4446#issuecomment-562798214
So I use the mosaic+yolov3_16000.weigts
in backup
file to continue training.
But it produce Nan again about 25k steps as shown following
(it breaks at 24k steps )
@nyj-ocean
I improved mosaic=1 for Detector. Try new mosaic. Two commits: https://github.com/AlexeyAB/darknet/commit/87f36b79f54ac0b84512a3c1c4284d31d100f6f7 and https://github.com/AlexeyAB/darknet/commit/13f064f1be1ccf28fae002349ba53fbf61a122a5
@AlexeyAB
Thanks.
By the way, can I set mosaic=1
and activation=swish
in yolov3.cfg
,and train with darknet53.conv.74
to further improve mAP like following?
[net] batch=32 subdivisions=16 width=416 height=416 channels=3 momentum=0.9 decay=0.0005 angle=0 saturation = 1.5 exposure = 1.5 hue=.1 mosaic=1 ... ... [convolutional] batch_normalize=1 filters=32 size=3 stride=1 pad=1 activation=swish
@AlexeyAB
I only replace activation=swish
with activation=leaky
in yolov3.cfg
,and use darknet53.conv.74
to train.
It do not get any improvement in mAP
, but decrease a bit.
@nyj-ocean
darknet53.conv.74
is trained with leaky-relu. You should retrain darknet53 classifier with swish.
Re-train Darknet53.cfg classifier with activation=swish
and mosaic=1 cutmix=1
on ImageNet then do partial
/.darknet partial cfg/darknet53_448.cfg darknet53_448.weights darknet53.conv.74 74
and use this new pre-trained weights darknet53.conv.74
for training detector with activation=swish
and mosaic=1
@AlexeyAB
I set mixup=1
in yolov3.cfg
, and use my own dataset to train with darknet53.conv.74
.
After training, I use the best.weights
in the backup
file to calculate mAP with the following command:
./darknet detector map my_obj.data mixup+yolov3.cfg backup/best.weights -points 0
It gets a 0.6% improvement in mAP
I am not sure this improvement in mAP
is just for random or for the mixup=1
@nyj-ocean In such cases, they usually train 3 times with mixup=1 and 3 times without, and take average accuracy.
But instead I suggest to train Detector with new mosaic=1
@AlexeyAB
I will try to set mosaic=1
in yolov3.cfg
, and train with darknet53.conv.74
in latest repo.
@AlexeyAB
I set mosaic=1
in yolov3.cfg
, and train with darknet53.conv.74
in latest repo.
(dataset: 1500 images for training set ,other 1500 images for val set)
After training, I use the best.weights
in the backup
file to calculate mAP with the following command:
./darknet detector map my_obj.data mosaic+yolov3.cfg backup/best.weights -points 0
It gets a 0.2% improvement in mAP
compared with yolov3
mixup+yolov3
gets a 0.6% improvement in mAP
compared with yolov3
as shown in https://github.com/AlexeyAB/darknet/issues/4446#issuecomment-562935289
@nyj-ocean Do you use the latest version of Darknet?
@AlexeyAB https://github.com/AlexeyAB/darknet/issues/4446#issuecomment-562856479
@nyj-ocean I improved mosaic=1 for Detector. Try new mosaic. Two commits: 87f36b7 and 13f064f
I download this repo and start to train mosaic+yolov3
just after when you improved mosaic=1 https://github.com/AlexeyAB/darknet/issues/4446#issuecomment-562856479
Hi, @AlexeyAB .
How to use mixup in training networks?
How to see the changes in training images and save them?