thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

Training on a new dataset to include more classes than the given 20 #536

Open parthdoshi84 opened 6 years ago

parthdoshi84 commented 6 years ago

I have followed the instructions given for training on my own data set. I want to include more classes apart from the twenty for which the model is trained for. To start with, for testing purposes, I took an image given in the test folder (images) and it's corresponding annotation file in the test folder(annotations). I downloaded the tiny-yolo-voc.cfg file and tiny-yolo-voc.weights file from the link given and renamed the tiny-yolo-voc.cfg to tiny-yolo-voc-test.cfg file. From here on, I tried two approaches:

1) I changed the number of classes to 3(two of them were objects contained in my training image), modified the number of filters in the last layer accordingly and changed the labels.txt file to include the corresponding labels. Then I trained the model (with tiny-yolo-voc-test.cfg file and tiny-yolo-voc.weights file), and let it run to completion (1000 epochs). As per my understanding, the newer weights are saved in the corresponding .meta file in the ckpt directory. Then I used the following command :
flow --model cfg/tiny-yolo-voc-test.cfg --load -1 --savepb

By doing this, I have a built_graph directory with the corresponding .meta and .pb file. As per the instruction:

"If you'd like to load a .pb and .meta file when using return_predict() you can set the "pbLoad" and "metaLoad" options in place of the "model" and "load" options you would normally set.",

I created a python file with the given code and used the .pb and ,meta file for classifying the images given in the test folder. Here only for the image sample_person.jpg , output is obtained. For all other images, no output is obtained. As "person" was present in the training image and also was included in one of the three classes in the labels.txt file, I am assuming that the model got trained to classify just three classes.

2) For my second approach, everything was the same as first except that now I included all twenty classes in the labels.txt file and modified the last layer of the configuration file accordingly. Still I got the same result.

What should I do to make my model be trained for additional classes (I don't want to lose it's ability to classify all the pretrained class objects). ? Is what I have done correct? If not, what should I be doing to achieve my goal. Thanks in advance.

michaeldu1 commented 5 years ago

BUMP. was there any resolution to this?