Yolo How to train the classification network???

Source: Internet
Author: User

The engineering application of general YOLO is directly detected, which originates from the pre-training model provided by the author, but what if I change the network training. The pre-training network does not do.

Not afraid, two methods can be solved.

The first: The more stupid way is to download imagenet data training Classification network.

The second kind: a layer of change network, each change layer, in the original pre-training conditions to train the network, the generation of new models as the next time to modify the Web pre-training model. It seems that it is not very clear that the problem will be discussed later.


Today, we discuss how to train your own classification model with YOLO. It can be seen that our general classification works are done by Caffe, Yolo in fact, and YOLO is pure C, has irreplaceable advantages. Add Openblas, the effect is not too good.


First step: YOLO configuration

This is not mentioned in this blog, can refer to my series of blog http://blog.csdn.net/samylee/article/details/53414108


Step Two: Data production

No special requirements, as shown in the image below, train save the training picture, test Save the testing picture, Labels.txt for the classification of the label, such as Cat and dog War is cat and dogs.

Note that the picture name is one of the labels.txt, for example, Cat_1.jpg,cat is one of the labels, after _1 casually write, as long as there is no dog on the line. (why.) Global Search Strstr function can be enlightened)


At the same time to generate Train.list and test.list to save the image train and test absolute path, this program can write their own, very simple.


The third step: data configuration file making

such as the cat and dog War data, cat_dog.data how to write. As follows:

classes=2
Train  = data/cat_dog/train.list
valid  = data/cat_dog/test.list
labels = Data/cat_dog /labels.txt
backup = cat_dog/backup/
top=2
Obviously, classes represents a few classes, labels represents the label path, backup indicates where to store the model, top indicates the accuracy of the output before, similar to Caffe.


Fourth Step: Network file making

Cat_dog.cfg how to write. As follows:

[NET]
batch=128
subdivisions=1
height=416
width=416
channels=3
max_crop=428
min_crop=428

hue=.1
saturation=.75
exposure=.75

learning_rate=0.1
policy=poly
power=4
max_ Batches =
momentum=0.9
decay=0.0005

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[Maxpool]
size=2
stride=2

[ Convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation= Leaky

[Maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[convolutional]
filters=2
size=1
stride=1
pad=1
activation=leaky

[Avgpool]

[Softmax]
Groups=1

[cost]
Type=sse
Obviously, Max_crop represents the original image size, heights and weights represent the size of the cut image, and the last layer conv output to several categories, such as Cat and dog 2.


Fifth Step: Training

It's very comfortable at this step. The terminal writes the following command:

./darknet Classifier Train Cfg/cat_dog.data cfg/cat_dog.cfg
What to look at during the training process. See Loss,loss should be smaller, and finally tend to smooth.


Sixth step: Test

After training, take out the training results of the model to test, leather. The terminal enters the following command:

./darknet classifier predict Cfg/cat_dog.data cfg/cat_dog.cfg cat_dog_final.weights data/dog.jpg
End, the terminal can see output two results (top=2), the first is the result of judgment.


Any questions please add unique QQ2258205918 (name Samylee)!!!

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.