Darknet: Can We Use Pre-Train Weights and add new classes to it.

Created on 20 Aug 2018  路  7Comments  路  Source: AlexeyAB/darknet

I have Trained 6 classes and got yolo_5000.weights file.
Now I wanted to add 4 more new classes to my existing classes instead of going and retraining my all my classes (10 classes ) can we do something to reuse the pre-train models or any alternative.
Any help from anyone would be useful for me and for new yolo users.
Because I have searched a lot even seen yolo doc but found something call transfer learning but don't know how to implement it because new to yolo.

Most helpful comment

Is there any way to use more than one weight for prediction for example

No.

The best way is: https://github.com/AlexeyAB/darknet/issues/1450#issuecomment-414445651

All 7 comments

You have to retrain your weights if number of classes changed.
What command did you use to train for 6 classes?
You just follow Alexey's instructions and update number of filters and classes in .names .data .cfg files. Then just use youryolo_5000.weights instead of darknet53.conv.74

@silvernine209
Thank's for the quick response,
I use this command

./darknet detector train data/obj.data yolo-obj.cfg darknet53.conv.74

so if i use this will this command speed up the process in traning

./darknet detector train data/obj.data yolo-obj.cfg yolo_5000.weights

Because I am getting 5 to 8 new products (to train) every day so what do you suggest me to do.

@syedmustafa54 AlexeyAB will tell you that you need to retrain when number of classes change. I would update obj.data and yolo-obj.cfg with new classes and just use darknet53.conv.74 to train again from beginning. If you want to expedite training, you can do fine tuning instead of transfer learning.
By default, AlexeyAB's repo will make your model to perform transfer learning, you can do fine-tuning by modifying yolo-obj.cfg, and this information is covered in AlexeyAB's repo as well.

Hi @AlexeyAB and @silvernine209
To be more clear Please say "Yes" or "No" here is my Problem
I have trained a model of 10k products (Classes) and got yolo_5000000.weights now
now I am getting 2 to 5 new Products per day I want to add this products to my trained data so is this possible or not
If Possible Yes:-How
If Not Possible No:-Why

@syedmustafa54

If your cfg-file is based on yolov3.cfg then do:

  1. ./darknet partial yolo.cfg yolo_5000000.weights yolo.conv.81 81

  2. Change classes= and filters= in 3 places in your yolo.cfg-file, also change obj.data and obj.names

  3. Train old+new classes by using command:
    ./darknet detector train obj.data yolo.cfg yolo.conv.81

Training may be will go faster than by using darknet53.conv.74

@AlexeyAB
Thank's for the quick response, Alexey
So no one tried it and the answer is "No" But I will give a try to it and reply

I Was thinking instead of retraining and making it 1 weight file I will train new models separate like yolo_12kProducts.weights and yolo_1kProducts.weights

Is there any way to use more than one weight for prediction for example
./darknet detect cfg/yolov3.cfg yolo_12kProducts.weights yolo_1kProducts.weights data/dog.jp
So this can Solve My Problem Or do you have any other Idea better than this

Is there any way to use more than one weight for prediction for example

No.

The best way is: https://github.com/AlexeyAB/darknet/issues/1450#issuecomment-414445651

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zihaozhang9 picture zihaozhang9  路  3Comments

off99555 picture off99555  路  3Comments

PROGRAMMINGENGINEER-NIKI picture PROGRAMMINGENGINEER-NIKI  路  3Comments

hemp110 picture hemp110  路  3Comments

kebundsc picture kebundsc  路  3Comments