Generate Caffe under windows+vs2013 and perform CIFAR10 classification test

Source: Internet
Author: User

http://blog.csdn.net/naaaa/article/details/52118437Tags: windowsvs2013caffecifar102016-08-04 15:33 1316 People read Comments (1) favorite reports Classification:Caffe

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

1. Download vs2013, install

Http://download.microsoft.com/download/0/7/5/0755898A-ED1B-4E11-BC04-6B9B7D82B1E4/VS2013_RTM_ULT_CHS.iso

2. Download Caffe source code, unzip

Https://github.com/Microsoft/caffe

Remove the. Example behind the Caffe-master/windows CommonSettings.props.example.

3.GPU Configuration

Configuration with GPU:

Download Cuda:

Https://developer.nvidia.com/cuda-downloads

Select the downloaded version according to your video card

Double-click EXE to install

Download CUDNN:

Https://developer.nvidia.com/cudnn

Download V4 or V5 version

After decompression, respectively, the LIB, include, bin folder files are copied to the Cuda installation directory under the Lib, include, bin folder

(Default: C:\Program files\nvidia GPU Computing toolkit\cuda\vx.x)

GPU-Free configuration:

Notepad to open caffe-master/windows under Commonsettings.prop Modify:

<CpuOnlyBuild>false</CpuOnlyBuild> for <CpuOnlyBuild>true</CpuOnlyBuild>

<UseCuDNN>true</UseCuDNN> for <UseCuDNN>false</UseCuDNN>

To compile each project before setting:

Properties---Property---Configuration Properties->c/c++-> preprocessor---preprocessor definitions, adding an item cpu_only

4. Generate Libcaffe

Open the Caffe.sln under Caffe-mastetr/windows

All projects need to be libcaffe.lib, so the first one to compile this project.

Libcaffe has a lot of relevant libraries, and the project has been configured to download with NuGet.

We need to install the NuGet Package Manager and start it.

Download NuGet:

Tools, extensions and updates, online, search nuget, download NuGet package management

(You can also download Http://docs.nuget.org/consume/installing-nuget website directly, double-click Install)

Start NuGet:

Right-click Project, enable NuGet package restore.

The resulting Libcaffe will be generated under Caffe-master\build\x64\debug libcaffe.lib

(all subsequent EXE files are also generated in this directory)

5.CIFAR10 Training Data

Http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz

Download data to Caffe-master\data\cifar10, unzip.

The downloaded data is in binary format and needs to be converted to LEVELDB.

Compile the Convert_cifar_data project and generate the Convert_cifar_data.exe.

Open CMD,CD to Caffe-master\build\x64\debug and enter the command (all subsequent commands are under this path):

Convert_cifar_data.exe. /.. /.. /data/cifar10/cifar-10-batches-bin. /.. /.. /data/cifar10 Leveldb

Generate Cifar10_test_leveldb and Cifar10_train_leveldb folders under the Caffe-master\data\cifar10 folder

6. Calculate the data image mean value

Compile Compute_image_mean project, generate Compute_image_mean.exe

CMD input command:

Compute_image_mean.exe. /.. /.. /data/cifar10/cifar10_train_leveldb. /.. /.. /data/cifar10/mean.binaryproto--backend=leveldb

7. Training CIFAR10 Model

Open Caffe-master\examples\cifar10\cifar10_quick_solver.prototxt File:

Modify path: Examples/cifar10 for. /.. /.. /examples/cifar10 (two places)

Modify the last behavior: solver_mode:cpu (do not change this one with the GPU)

Open caffe-master\examples\cifar10\ Cifar10_quick_train_test.prototxt file:

Modified Backend:lmdb to Backend:leveldb (two places)

Modify Mean_file: "Examples/cifar10/mean.binaryproto" for Mean_file: ". /.. /.. /data/cifar10/mean.binaryproto "(Two places)

Modify Source: "Examples/cifar10/cifar10_train_lmdb" as Source: ". /.. /.. /data/cifar10/cifar10_train_leveldb "

Modify Source: "Examples/cifar10/cifar10_test_lmdb" as Source: ". /.. /.. /data/cifar10/cifar10_test_leveldb "

Compile Caffe project, generate Caffe.exe

CMD input command: Caffe.exe train--solver=. /.. /.. /examples/cifar10/cifar10_quick_solver.prototxt Training Network

CPU training will be trained for a long time, after the completion of training Caffe-master/examples/cifar10 folder generated

Cifar10_quick_iter_4000.caffemodel.h5

Cifar10_quick_iter_4000.solverstate.h5

8. Classification of images

Create a new text file Synset_words.txt under Caffe-master\data\cifar10.

The content of the file is the category of classification contained in Cifar10, as follows:

[Plain]View PlainCopyprint?
    1. Airplane
    2. Automobile
    3. Bird
    4. Cat
    5. Deer
    6. Dog
    7. Frog
    8. Horse
    9. Ship
    10. Truck

Compile classification project, generate Classification.exe

Command Line Input:

Classification.exe. /.. /.. /examples/cifar10/cifar10_quick.prototxt. /.. /.. /examples/cifar10/cifar10_quick_iter_4000.caffemodel.h5. /.. /.. /data/cifar10/mean.binaryproto. /.. /.. /data/cifar10/synset_words.txt. /.. /.. /examples/images/cat.jpg

Will come out and classify the results, my results:

[Plain]View PlainCopy print?
    1. ----------prediction for. /.. /.. /examples/images/cat.jpg----------
    2. 0.9784-"Deer"
    3. 0.0100-"Cat"
    4. 0.0094-"Bird"
    5. 0.0017-"Frog"
    6. 0.0004-"Dog"

Reference post: http://blog.csdn.net/zb1165048017/article/details/51476516

Generate Caffe under windows+vs2013 and perform CIFAR10 classification test

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.