Yolo Train your dataset.

Source: Internet
Author: User
Tags python script

It's nice to have hundreds of people who have successfully used YOLO to process their datasets through my tutorials.

Recently, the CNN model has been used to do image two classification, but suffers from poor results, so the image classification problem as a target recognition problem. Do target recognition selected YOLO (you just look once), a recently introduced method, the outstanding advantage is speed. Looking up the internet about the YOLO of training their own data sets of methods, most of the problem, and YOLO recently updated to the Version2 version. After their own experiments, the use of YOLO written experience.

1.yolo
Yolo's official website: https://pjreddie.com/darknet/yolo/
Yolo's official website describes the installation and testing of YOLO. I suggest that you look at the English official website, because the Chinese network updated slowly, and some of the content omitted. Follow the official website steps will not be wrong.

2. Preprocessing of data
The YOLO data includes training data and validation data (training data used to train the model and validate the data to adjust the model). Training data and validation data include: A. Picture; b. label. It should be explained that if VCC is used, the label needs a specific XML format and is converted to txt. Here is my goal to detect "cat" as an example to explain.
A. Store all picture samples (including training and validation data, preferably in JPG format) under the "Image" folder
B. Download labelimg (an image marking tool, to the image of the target tag, and can generate training needs of the XML format), the specific use of the method can be Baidu, easy to operate.
c. Creates a new XML folder with the same sibling as the image folder, and the XML folder holds the label of all picture samples that labelimg gets.
d. Now it's time to divide all the samples into training sets and validation sets, and separate the XML for the training set and the validation set. Here, download the Python script and put it directly in the "Image" and "XML" folder sibling paths.

Download:
Link: http://pan.baidu.com/s/1hs22I7U Password: wdv0
Run traindata.py: Generate Trainimage folder, store training picture, generate Trainimagexml folder, store training picture XML tag, generate Validateimage folder, store validation set picture, generate Validateimagexml folder, store test The XML tag for the picture of the proof set.
Run trans.py, generate Trainimagelabeltxt folder, store the training pictures through the XML tags translated txt file (if the training process prompts TXT file can not be found, then the TXT folder under this folder to move to the Trainimage folder); Generate Valida Teimagelabeltxt folder, the same reason. The
additional trainImagePath.txt and ValidateImagePath.txt store the path to the training picture and verify the picture.

3. Modify the configuration file
The next step is to modify the configuration file:
In a. Cfg/voc.data Document:
Classes= 1
Train =/home/pdd/pdwork/darknet2/darknet/voc/cat/trainimagepath.txt
valid =/home/pdd/pdwork/darknet2/darknet/voc/cat/validateimagepath.txt
names = data/cats.names
Classes The total number of categories (only cat one), train and valid are the path to the training picture and verify the picture, cats.names the box annotation, there is only cat line:

b. yolo-voc.cfg
Change the classes in [region] to 1 (only cat type), and change the last [convolutional] (next to [region] previous) filter to the formula for filter (filters= coords+ 1) * (NUM), mine is (1+4+1) * 5=30).
c. cats.names
In the Data folder under the new Cats.names, see the specific a.

4. Download the pre-training document CFG/DARKNET19_448.CONV.23
Take the Pretrain model on the other dataset as the initial value and download the address:
Link: http://pan.baidu.com/s/1dFgUk4x Password: ynhg. Put it under the Darknet folder.

5. Training
To run the command under the Darknet folder path:
./darknet Detector Train Cfg/voc.data cfg/yolo-voc.cfg cfg/darknet19_448.conv.23
The system defaults to iterate 45,000 times batch, if you need to modify the number of training, enter cfg/yolo_voc.cfg modify Max_batches value.
6. Test
After the training is completed, the model is successfully saved and the input command tests the model:
./darknet detector Test Cfg/voc.data cfg/yolo-voc.cfg backup/yolo-voc_final.weights testpicture/001.jpg

The above is the result of using Yolo2 to train your own dataset, which has been tested through. Little Buddy, try it quickly. There are questions welcome message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.