qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)
MIT License
7.14k stars 3.44k forks source link

How to train own dataset? #264

Open ybdesire opened 5 years ago

ybdesire commented 5 years ago

Which code should I modify if I want to train my own dataset?

fnando1995 commented 4 years ago

@SrikarNamburu no needed. Convert.py change from darknet to keras your model.

The architecture in yolov3.cfg is defined for 80 classes, right? Also, I have edited 'model_data/coco_classes.txt' to my dataset -- removed 80 classes and have put only my 15 classes.

yes, for training yo need to change that .cfg.

@robisen1 there should be no problem in angle of the image. detection will be done as long as you data is good.

robisen1 commented 4 years ago

@SrikarNamburu no needed. Convert.py change from darknet to keras your model.

The architecture in yolov3.cfg is defined for 80 classes, right? Also, I have edited 'model_data/coco_classes.txt' to my dataset -- removed 80 classes and have put only my 15 classes.

yes, for training yo need to change that .cfg.

@robisen1 there should be no problem in angle of the image. detection will be done as long as you data is good.

ok thank you I will attempt.

SrikarNamburu commented 4 years ago

@SrikarNamburu no needed. Convert.py change from darknet to keras your model.

The architecture in yolov3.cfg is defined for 80 classes, right? Also, I have edited 'model_data/coco_classes.txt' to my dataset -- removed 80 classes and have put only my 15 classes.

yes, for training yo need to change that .cfg.

@robisen1 there should be no problem in angle of the image. detection will be done as long as you data is good.

Thanks for the suggestions. Now I am training the model, but the val_loss = nan why is this happening? And what's the optimal loss value to stop the training?

SrikarNamburu commented 4 years ago

@fnando1995

Also after saving the model after training how to test it?

aimxu commented 4 years ago

@SrikarNamburu Im afraid that not good sitution, because nan means the val_loss can not be presented, usually caused by divided by zero in the loss function, lowing the learning rate maybe helped. after training, you should use the new generated weight file .h5 to test just following the README, but dont forget the anchor I hope it may little help for you.

SrikarNamburu commented 4 years ago

@aimxu @fnando1995 When training, my loss=21, what does 21 mean? What does it say?

Thank you

aimxu commented 4 years ago

@SrikarNamburu It happen all the time

  1. you can just follow the README in usage section, python yolo_video.py --image, while testing you should type image path following the prompt , and you can change the detect_img function in yolo_video.py to suit you application.
  2. According to the code, the loss is something called lambda loss (I have no time to get inside it, It may be the loss function in the original yolov3, consume the code may be helped), The loss is about 7 in my situation, It performs quite well。 image
SrikarNamburu commented 4 years ago

Thank you so much For val_loss = nan you have suggested lowering the learning rate, in yolov3.cfg its by default 0.001 should I lower it even further to like 0.0001?

aimxu commented 4 years ago

@SrikarNamburu yes, general speaking we try 1/10 of the learning rate. But the side effect of lower the learning rate is the process for converge is slow. So if you dataset is not so big, You can try several times!

SrikarNamburu commented 4 years ago

@fnando1995 @aimxu I have reduced the learning rate to 0.0005 still no luck. I am using pre-trained coco weights. My train dataset size is 176 images with 15 classes. Only 2 classes are new i.e which are not in coco. 13 classes already there in coco so I just took 2 to 5 images for those 13 classes. Does the val_loss = nan have anything to do with this?

aimxu commented 4 years ago

You may try 1 class, with the pretrain weight, you should easy to train even with few data, maybe

  1. your data is not ready for training, some image may not appropriate to coco
  2. there is something wrong while your training, class.name, anchor or something? good luck
robisen1 commented 4 years ago

@SrikarNamburu no needed. Convert.py change from darknet to keras your model.

The architecture in yolov3.cfg is defined for 80 classes, right? Also, I have edited 'model_data/coco_classes.txt' to my dataset -- removed 80 classes and have put only my 15 classes.

yes, for training yo need to change that .cfg.

@robisen1 there should be no problem in angle of the image. detection will be done as long as you data is good.

I actually found it a huge issue. I experimented with multiple approaches but determined you need imagery that would match the angles the drone would fly. Unfortunately there are no good annotated datasets so I had to get a few 10's of thousands of images annotated. I then trained on the data and yolo worked very well.