出于在csdn上面学到很多东西这里也帮自己的一些收获和大家分享一下
直奔主题~~
前提是已经安装好caffe的环境 本文是在Ubuntu 15.04下做的测试 $Faster_rcnn表示py-faster-rcnn根目录
1. 修改数据接口 ($Faster_rcnn/lib/datasets)
目录下面的pascal_voc.py是主要的数据读取接口
- self._classes = ('__background__', # always index 0
'bottle', 'bus', 'car', 'cat', 'chair',
'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedplant',
'sheep', 'sofa', 'train', 'tvmonitor')
这里定义了要训练的类别,修改这里为自己需要训练数据的类标签,注意总类别包括背景
- 如果需要使用PASCAL数据库中的个别类 需要在
if not self.config['use_diff']:
# Exclude the samples labeled as difficult
non_diff_objs = [
obj for obj in objs if int(obj.find('difficult').text) == 0]
# if len(non_diff_objs) != len(objs):
# print 'Removed {} difficult objects'.format(
# len(objs) - len(non_diff_objs))
objs = non_diff_objs
########################################
valid_class_objs = [
obj for obj in objs if obj.find('name').text in self._classes]
objs = valid_class_objs
########################################
num_objs = len(objs)
添加#两行中间部分
2. 修改模型参数($Faster_rcnn/models/pascal_voc)
其中有三种网络模型 VGG16 ZF VGG_CNN_M_1024
硬件需要参考RGB大神写的
Requirements: hardware
- For training smaller networks (ZF, VGG_CNN_M_1024) a good GPU (e.g., Titan, K20, K40, ...) with at least 3G of memory suffices
- For training Fast R-CNN with VGG16, you'll need a K40 (~11G of memory)
Usage
To train and test a Faster R-CNN detector using the alternating optimization algorithm from our NIPS 2015 paper, useexperiments/scripts/faster_rcnn_alt_opt.sh
. Output is written underneath $FRCN_ROOT/output
.
cd $FRCN_ROOT
./experiments/scripts/faster_rcnn_alt_opt.sh [GPU_ID] [NET] [--set ...]
# GPU_ID is the GPU you want to train on
# NET in {ZF, VGG_CNN_M_1024, VGG16} is the network arch to use
# --set ... allows you to specify fast_rcnn.config options, e.g.
# --set EXP_DIR seed_rng1701 RNG_SEED 1701
("alt opt" refers to the alternating optimization training algorithm described in the NIPS paper.)
To train and test a Faster R-CNN detector using the approximate joint training method, useexperiments/scripts/faster_rcnn_end2end.sh
. Output is written underneath $FRCN_ROOT/output
.
cd $FRCN_ROOT
./experiments/scripts/faster_rcnn_end2end.sh [GPU_ID] [NET] [--set ...]
# GPU_ID is the GPU you want to train on
# NET in {ZF, VGG_CNN_M_1024, VGG16} is the network arch to use
# --set ... allows you to specify fast_rcnn.config options, e.g.
# --set EXP_DIR seed_rng1701 RNG_SEED 1701