最近要用C3D来抽取特征,以后也会经常用到,所以这里把C3D抽取特征的几个重要步骤总结一下:
1、将C3D clone 到本地
git clone https://github.com/facebook/C3D.git
2、编译C3D
3、先测试一下能否运行
cd examples/c3d_feature_extraction
sh c3d_sport1m_feature_extraction_frm.sh
4、将视频抽取成图像帧(也可以以视频为单位抽取特征,但是这里只讲以帧为单位去抽取C3D特征)
5、准备input_list_frm.txt文件,其文件格式为
<frame_path> <starting_frame> <label>
./input/train198_frames/video_validation_0000940/ 1 0
./input/train198_frames/video_validation_0000940/ 17 0
6、创建文件夹用于装载抽取好的特征(每个视频一个文件夹),并准备output_list_frm.txt,其文件格式为
<output_prefix> <starting_frame>
./output/train198_ori_fea/video_validation_0000940/000001
./output/train198_ori_fea/video_validation_0000940/000017
7、修改prototxt/c3d_sport1m_feature_extractor_frm.prototxt
source: "prototxt/input_list_frm.txt" %改为对应的文件
use_image: true
mean_file: "sport1m_train16_128_mean.binaryproto" %改为相应的模型
batch_size: 50 %改为想要的batchsize
crop_size: 112
mirror: false
show_data: 0
new_height: 128
new_width: 171
new_length: 16
shuffle: false %确认此处为false
8、修改c3d_sport1m_feature_extraction_frm.sh
对应的修改规则为
extract_image_features.bin <feature_extractor_prototxt_file>
<c3d_pre_trained_model> <gpu_id> <mini_batch_size>
<number_of_mini_batches> <output_prefix_file> <feature_name1>
<feature_name2>
GLOG_logtosterr=1 ../../build/tools/extract_image_features.bin prototxt/c3d_sport1m_feature_extractor_frm.prototxt conv3d_deepnetA_sport1m_iter_1900000 0 50 1 prototxt/output_list_prefix.txt fc7-1 fc6-1 prob
其中mini_batch_size与number_of_mini_batches的乘积要大于所要抽取的特征的总数