yolov3 (darknet version) trains its own VOC format data set

One, get the data set

1. If you can download the labeled data set, you can use it directly. Pay attention to check whether the organization format of the data set is the same as the VOC format.

2. If you don't have a ready-made data set, you may need to label it yourself. I will elaborate on this later if I have the opportunity. Need to use some labeling tools, such as labelImg, the specific use method can refer to the following two articles! ! !

Use labelImg to label images under windows

labelImg installation instructions

2. Download and compile darknet (under Ubuntu)

1. Download and compile

git clone https://github.com/pjreddie/darknet.git
cd darknet
make

2. After the compilation is complete, you can use the following command to check

./darknet

If there is no problem, the following information will be output:

usage: ./darknet <function>

3. If you want to support GPU and OPENCV, you can modify it before compiling, and modify Makefilethe value of the item to be compiled to 1, as shown below:
Insert picture description here
For details, please refer to the official documents: https://pjreddie.com/darknet/install/

3. Convert VOC data set format to YOLO data format

The previous article has explained in detail, Portal: VOC format data set to yolov3 (darknet) format

Another point is that you can VOCdevkitrun the following command in the same level directory after the format is converted :

cat 2007_train.txt 2007_val.txt  > train.txt

The purpose is to merge the training data and the verification data into one file, and both are used for training. This is not necessary, but I think others do it like this, emmm! ! !

Four, parameter modification

The main areas that need to be modified are as follows:

1. cfg/voc.dataFile : just modify it according to your actual path. Backup is used to store the weights after training.
Insert picture description here
2. data/voc.namesFile : Modify according to the actual type and category name of your own data set.
Insert picture description here
3. cfg/yolov3-voc.cfgDocuments :

  • filtersAnd classesparameters; there are three parts, the quickest way is to search directly yolo, and then change the filterssum above classesto the actual value you need. These two values ​​satisfy the following formula:
filters = 3*(5+len(classes));
classes = len(classes)

Insert picture description here

  • Other basic parameters: For example, during training, comment out lines 6 and 7, and comment out lines 3 and 4. Other parameters such as the number of iterations can also be modified as needed.

Insert picture description here

Five, training

1. Download the pre-trained model of darknet53

wget https://pjreddie.com/media/files/darknet53.conv.74

2. Start training:

./darknet detector train cfg/voc.data cfg/yolov3-voc.cfg darknet53.conv.74

Six, summary

If you don't want to use it, you yolov3-voc.cfgcan just select the profile you want to use, and then select the pre-training weight that matches the model structure.

Different configuration files correspond to different network structures ( so you have to choose matching pre-training weights ) or parameters. For example, to make the model smaller, you can choose yolov3-tiny.cfg, as long as you remember that the weight file generated after the training is completed corresponds yolov3-tinyto it. In this way, when you load the weights file will be loaded re-structure the right model is also set yolov3-tinyon it.

Guess you like

Origin blog.csdn.net/qq_39507748/article/details/110826017
Recommended