Caffe windows+visual studio 2013+cuda8.0 training own data experience

I used a classification of images made by the AlexNet model, and in the initial stage, I accumulated some experience and shared it. The premise of doing the following steps is to successfully train caffe first.

1. Create a .bat command file to convert the data into an mtraindb file. (I have a little experience, you can write a program by yourself to automatically read the folder pictures and generate txt files. I used matlab to compile, save a lot of effort, you can choose a language you are familiar with, python, c++, ... are all possible)

The steps are: 1. Create a train folder and put the training set image classification number into it.


2. Create a train.txt folder and input the training set image label file into the txt file.


3. The principle is the same as that of 1, and the val test set picture folder is established.


4. The principle is the same as 2, create a val.txt file


5. Create a new .bat command file to convert the image data into an mtraindb file. (When writing, be sure to pay attention to path selection and spaces, etc.)


Training process display:


The successfully converted folders are:


2. The means.bat command file calculates the mean file.

Step 1. Create the means.bat command file,

2. Run the .bat file. You must pay attention here. When running, you will be prompted whether each image can be successfully read. Sometimes all the pictures may not be completely read. At this time, you should check the name when you create a txt file. is it right or not. My experience is that there can't be too many spaces.


3. The training begins

Step 1. Create the strat.bat command file to start training the model.


2. Modify the train_val.protxt file. Pay special attention to the size of batch_size. If the setting is too large, it will cause memory overflow. If your GPU is relatively small, set a value less than 100. If the memory overflows, it depends on the situation. Let’s set it smaller, and a special note is that the output type should be set to the type that you want to classify. There are 1000 categories in the original model.


3. Modify the solver.txt file. The solver file is a parameter configuration file. Here you can set the save path of your model, the frequency of the accuracy.loss value, and the final number of iterations.


4. Click to run the .bat file to start training. The saved model is:


4. Test classification results

Step 1. Create a category.txt file to define the identification type.

2. Create a folder of images to be tested.

3. Create the result.bat command file to test the model performance.


To produce results like this is to successfully complete your own training.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325337881&siteId=291194637