qqwweee / keras-yolo3

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

Documentation on training on own dataset #484

Open ghurtado1097 opened 5 years ago

ghurtado1097 commented 5 years ago

I am trying to train the converted YOLOv3 model with pretrained weights and by using my own class (single class inside the file classes.txt) and my own anchors created with kmeans.py.

However after successful training, running YOLO on a single image, I get a mismatch error: "Mismatch between model and given anchor and class sizes". It is not clear to me and also missing from the documentation where the mismatch results. If I use pretrained weights and train on my own dataset, aren't the last fully connected layers of the model adapted to the new dataset in terms of output units, image width/height?

JulixQuid commented 5 years ago

Did you make sure your that the NEW classes and anchors files are being loaded in the yolo script?

syedmutti commented 5 years ago

Hey, I have the same problem, however I loaded the anchor files and new classes only in train.py and not yolo.py. Probably, it used the default values from yolo , IDK.

@ghurtado1097 , Did you figure out anything about it ?

hasansalimkanmaz commented 5 years ago

I have the same problem. Anyone with a solution?

syedmutti commented 5 years ago

@2008hsk , For me the problem was with classes.txt file (file with classes). Make sure your file has only as many number of lines as number of classes. Also, Load this file in ''yolo.py" as classes_path. I hope it works for you as well.

hasansalimkanmaz commented 5 years ago

My classes file have only as many numbers of lines as number of classes. I also changed path in the yolo script. But again it gives me the same mismatch error.

aseembh2001 commented 5 years ago

Hi, I manually changed the path to new trained weights file in model_path

_defaults = {

"model_path": 'model_data/yolo.h5',

"model_path": 'model_data/trained_weights_final.h5', "anchors_path": 'model_data/yolo_anchors.txt', "classes_path": 'model_data/camry.txt', "score" : 0.3, "iou" : 0.45, "model_image_size" : (416, 416), "gpu_num" : 1, }

This worked for me and was able to make custom detections

vgilabert94 commented 5 years ago

I have a question about "model_image_size" : (416, 416), what is the height and the width? Because I need to train with width:832 x 1248:height and i dont know how to write correctly in the file. Any help?