title: '【Caffe】Caffe command line and related tool usage methods "A Serious Talk about Caffe"'
date: 2017-07-27
permalink: /posts/2017/07/【Caffe】caffe-command-line-and-related-tool-usage-methods-a-serious-talk-about-caffe/
tags:
- Caffe
1. Caffe#
After compilation, we can train and test by running ./build/tools/caffe
Below, I will briefly introduce its usage:
commands:
train: train the model
test: call the test mode in prototxt, which evaluates the model using the validation set. You can also specify a new test set by modifying train_val.prototxt.
device_query: display GPU diagnostic information
time: calculate the execution time of the model
Flags:
-gpu: optional parameter, specifies which GPU device to use, default is 0. If set to 'all', it will use all available GPUs.
The actual batch size for multi-GPU training is GPU count × batch size.
-iterations: optional parameter for test mode. Default is 50, and it should ideally match test_iter in the solver.
-model: required parameter for test and time modes. Specifies the network structure text, train_val.prototxt.
-sighup_effect: action to take when receiving SIGHUP signal, optional: snapshot, stop, none. Default is snapshot.
-sigint_effect: same as above, default is stop.
-snapshot: restore training from the specified snapshot file xxxxxx.solverstate.
-solver: required parameter for train mode. Specifies the hyperparameter text.
-weights:
- required parameter for test mode. Specifies the trained xxxxxx.caffemodel.
- optional parameter for train mode. Specifies the caffemodel to be fine-tuned.
2. extract_features#
Path: ./build/tools/extract_features.bin
Parameter 1: xxx.caffemodel
Parameter 2: deploy.prototxt
Parameter 3: conv1 or conv2 or pool1, can be one or multiple separated by commas
Parameter 4: path to save the above feature maps
Parameter 5 (optional): number of data batches for feature extraction
Parameter 6 (optional): input data format (LMDB or LEVELDB)
Parameter 7 (optional): CPU or GPU
Parameter 8 (optional): if GPU is selected, choose the device number
3. Classification#
Path: ./build/examples/cpp_classification/classification.bin
Parameter 1: deploy.prototxt
Parameter 2: xxx.caffemodel
Parameter 3: mean.binaryproto
Parameter 4: words.txt
Parameter 5: xxx.jpg