pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.7k stars 21.33k forks source link

About training my own data #414

Open xiaomage11 opened 6 years ago

xiaomage11 commented 6 years ago

I use darknet to train my own dataes ,I want to use the model after training to recognize kinds of objects,for example, I have two classes,and after training I got a model about this two classes,now I want to add another class in them ,and I do not want to train all three classes again,I want to only train the new class based on previous model.and I can get the new model include three classes.please tell me how to do about it.Thanks very much.

Li-Lai commented 6 years ago

It shoule be impossible. Now that you're training a new class, why not train three together?

xiaomage11 commented 6 years ago

@CBIR-LL I do not know how many classes in it in the frist time ,so i can not determine the classes of objects.I should add the new classes according to project needs.If i add new class,i should train all classes together,it well be so many jobs.

Li-Lai commented 6 years ago

Check the previous data or configuration file to check the target category. If the previous data and the corresponding annotation information are still in, retrain, this will not take much time. At the same time, you can do other things...

toancong commented 6 years ago

The similar issue for me. I wonder that's possible if only pretrain just new one but having other classess which trained already? Thanks.

ahsan856jalal commented 6 years ago

put stopbackward=1 after 2nd last convolution layer and change filters of the last convolution layer (before region layer) to 40 ([3+5]*5) and classes to 3 in region layer and run train ./darknet detector train data/obj.data cfg/yourcfg,cfg last_trained_weight_on_two_classes.backup

ahsan856jalal commented 6 years ago

Make sure the new class has label '2' as previous two classes has labels '0 and 1' . stopbackward=1 in 2nd last layer will make sure that the weights before that layer won't change. This is called fine-tuning

Serge3006 commented 6 years ago

Hi I tried to finetune the network but I failed. I used the yolov2.weights provided on the website as the initial parameter. Also, I active the flag stopbackward in the 22 conv layer (I just want to fine tune the last layer). Finally, I modified the .names, .data and the number of filters in the last layer. However, when I run the line to train the net, it just saves the yolov2.weights with the name I want to save my new weights. It doesn't report any error, but do not train anything.

imagen

Do you have any idea why this is hapenning? Thanks

corentin87 commented 6 years ago

I failed because you didn't remove the last layer so the yolov2.weights that you use already corresponds to a yolov2.final.weights. You need to remove the last layer using the partial command. Or if you want to not do that you need to use a yolov2.weights from a previous check point (not the final one). For example yolov2_1000.weights. Although I don't know what you are trying to train and if your dataset is similar to the one used for yolov2.weights.

xiaomage11 commented 6 years ago

@Serge3006 Your method is followed by the original weight. You need to modify the value of max_batches in the previously trained cfg file to be larger than the previous one. For example, the original max_batches=10000, please change it to 11000 to train.

xiaomage11 commented 6 years ago

@corentin87 Thanks for your answer, your answer to @Serge3006 question but not mine

corentin87 commented 6 years ago

@xiaomage11 you didn't manage to solve your problem?

xiaomage11 commented 6 years ago

@corentin87 I have already solved,thanks