extract_feature_example.sh:
#!/usr/bin/env sh
# args for EXTRACT_FEATURE
TOOL=./build/tools
MODEL=./examples/image_test/caffenet_train/caffenet_train_iter_5000.caffemodel #下载或自己训练得到的caffe model
PROTOTXT=./examples/image_test/train_val10.prototxt # 网络定义
LAYER=fc7 # 提取层的名字,如提取fc7等
LEVELDB=./examples/image_test/temp_features/features_fc7 # 保存的leveldb路径
BATCHSIZE=10
# args for LEVELDB to MAT
DIM=4096 # 需要手工计算feature长度
# DIM=290400 # feature长度,conv1
# DIM=43264 # conv5
OUT=./examples/image_test/temp_features/features_fc7.mat #.mat文件保存路径
BATCHNUM=4 # 有多少个batch,默认提取的都是val数据集的特征,200张图片,BATCHSIZE*BATCHNUM为提取的图片的总数200张
#提多了都是重复的,又从第一个batch提取
$TOOL/extract_features.bin $MODEL $PROTOTXT $LAYER $LEVELDB $BATCHSIZE lmdb
python lmdb2mat.py $LEVELDB $BATCHNUM $BATCHSIZE $DIM $OUT