keras-YOLOv3-mobilenet icon indicating copy to clipboard operation
keras-YOLOv3-mobilenet copied to clipboard

no test result

Open zhukkang opened this issue 6 years ago • 16 comments

as i trained the model on widerface dataset for face detection, the loss 875/875 [==============================] - 1327s 2s/step - loss: 13.1126 - val_loss: 13.7300 loos not decrease , and test no bbox output result.

do you know the reason

zhukkang avatar Jan 21 '19 09:01 zhukkang

one drawback of this implementation is that the loss can not reach 0 due to l2 regularization. You should check your threshold and the data format.

Adamdad avatar Jan 21 '19 09:01 Adamdad

my dataset format is /home/data/JPEGImages/34--Baseball_34_Baseball_Baseball_34_465.jpg 227,250,256,281,0 928,938,75,87,0 in one line each image and threshold is default as score_threshold=.6, iou_threshold=.5 also i just set one classes and label is 0

zhukkang avatar Jan 21 '19 09:01 zhukkang

you should try a smaller score_threshold(0.1 or 0.01 for example) to see if there is any result

Adamdad avatar Jan 21 '19 09:01 Adamdad

i tried 0.1,as some has result, but seems not correct, so i retrained based on the final model, but loss keep on >13 , so how can i reduce the loss

zhukkang avatar Jan 21 '19 09:01 zhukkang

what's your learning rate,batch size,input size?

Adamdad avatar Jan 21 '19 10:01 Adamdad

input_shape = (416,416) batch_size = 16 learning rate as use your default not changed lr=1e-3 (freeze) lr=1e-4(unfreeze)

zhukkang avatar Jan 22 '19 08:01 zhukkang

do you train when some layers are freezing?You should unfreeze all the layers when training.

Adamdad avatar Jan 22 '19 08:01 Adamdad

no, as i not change the freezing operation in the code

zhukkang avatar Jan 22 '19 08:01 zhukkang

also what about the memory usage with your GPU , as i tested with 980TI > 5GB

zhukkang avatar Jan 22 '19 08:01 zhukkang

You should train without frozen layers, so the change the code to 'False' in the frozen part

` if False: model.compile(optimizer=Adam(lr=1e-3), loss={ # use custom yolo_loss Lambda layer. 'yolo_loss': lambda y_true, y_pred: y_pred}) batch_size = 16 print('Train on {} samples, val on {} samples, with batch size {}.'.format(num_train, num_val, batch_size)) model.fit_generator(data_generator_wrapper(t_lines, batch_size, input_shape, anchors, num_classes), steps_per_epoch=max(1, num_train//batch_size), validation_data=data_generator_wrapper(v_lines, batch_size, input_shape, anchors, num_classes), validation_steps=max(1, num_val//batch_size), epochs=30, initial_epoch=0, callbacks=[logging, checkpoint]) model.save_weights(log_dir + 'trained_weights_stage_1.h5')

The GPU size is ok, because the batch size when testing is set to 1. So just 2GB of memory is enough.

Adamdad avatar Jan 22 '19 08:01 Adamdad

first time i trained with both frozen and unfrozen, second time ,i retrain with set the frozen as false like you said above based on the first step result model

but loss still not descrease

zhukkang avatar Jan 22 '19 08:01 zhukkang

as the dataset i trained on yolo v3 dosn't has such issue , and loss is ~ 1.8

zhukkang avatar Jan 22 '19 08:01 zhukkang

I am not pretty sure about the reason about the bad performance, but keras implementation has such fault that the loss cannot be as low as darknet implementation. A higher loss does not mean bad performance naturally, because the keras implementation use L2 regularization for so the loss the we see is naturally bigger than the real one.

Adamdad avatar Jan 22 '19 08:01 Adamdad

as i just want a good performance ,but now seems not , thanks for your replay, i will check it more

zhukkang avatar Jan 22 '19 08:01 zhukkang

as i just want a good performance ,but now seems not , thanks for your replay, i will check it more

hi kkang,have you solved the problem yet? I used the same WiderFace set as you and my train and val loss decrease to ~7 in 5th epoch. But my test result is very bad too. If you have any information about the problem, please contact me.

ChrisTiger93 avatar Aug 21 '19 05:08 ChrisTiger93

I am not pretty sure about the reason about the bad performance, but keras implementation has such fault that the loss cannot be as low as darknet implementation. A higher loss does not mean bad performance naturally, because the keras implementation use L2 regularization for so the loss the we see is naturally bigger than the real one.

hi, Adamad.I have the same problem as kkang and perhaps because we used the same WiderFace dataset. My train and val loss decrease to ~7 in 5th freeze epoch. But my test result is very bad too. Most score below 0.1 and the bbox is not correct too. My train data is organized by the following format: D:/WIDER_train/images/0--Parade/0_Parade_marchingband_1_849.jpg 449,330,122,149,0 150,262,1276,74,1 and my parameters are: input_shape = (416,416) batch_size = 16 lr=1e-3 (freeze) lr=1e-4(unfreeze)

ChrisTiger93 avatar Aug 21 '19 05:08 ChrisTiger93