faster r-cnn使用Pascal VOC2007+2012联合训练

1、首先下载07/12数据集

wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
2、解压到一个名为 VOCdevkit 的文件夹里

tar xvf VOCtrainval_06-Nov-2007.tar
tar xvf VOCtest_06-Nov-2007.tar
tar xvf VOCdevkit_08-Jun-2007.tar
tar xvf VOCtrainval_11-May-2012.tar
3、里面应该有的文件夹:

$VOCdevkit/                           # development kit
$VOCdevkit/VOCcode/                   # VOC utility code
$VOCdevkit/VOC2007                    # image sets, annotations, etc.
$VOCdevkit/VOC2012                    # image sets, annotations, etc.
# ... and several other directories ...
4、因为faster rcnn不支持多个数据集训练,所以我们要手动合并2007和2012,。方法是:首先新建一个叫VOC0712的文件夹,在VOCdevkit下面,把VOC2007和VOC2012下面除了ImageSets以外所有文件夹拷贝到VOC0712下面(需要合并一些文件夹),然后何凯明在R-FCN里提供了一个ImageSets文件夹,把它拷贝到V OCdevkit/VOC0712/ 

网址:https://github.com/Orpine/py-R-FCN

5、现在文件夹下面应该包含了

	$VOCdevkit/                           # development kit
	$VOCdevkit/VOCcode/                   # VOC utility code
	$VOCdevkit/VOC2007                    # image sets, annotations, etc.
	$VOCdevkit/VOC2012                    # image sets, annotations, etc.
	$VOCdevkit/VOC0712                    # you just created this folder
	# ... and several other directories ...
6、在faster r-cnn的data文件夹下创建软连接,$是绝对路径的意思,创建2007,2012,0712三个软连接,都连到VOCdevkit

cd $RFCN_ROOT/data
ln -s $VOCdevkit VOCdevkit2007
cd $RFCN_ROOT/data
ln -s $VOCdevkit VOCdevkit2012
cd $RFCN_ROOT/data
ln -s $VOCdevkit VOCdevkit0712
7、如果使用07+12,首先改一下数据集名称,打开py-faster-rcnn-master\experiments\scripts\faster_rcnn_end2end.sh

原代码:

case $DATASET in
  pascal_voc)
    TRAIN_IMDB="voc_2007_trainval"
    TEST_IMDB="voc_2007_test"
    PT_DIR="pascal_voc"
    ITERS=70000
    ;;

改为:

case $DATASET in
  pascal_voc)
    TRAIN_IMDB="voc_0712_trainval"    #这个名字是用来分解使用的,中间的数字就代表哪个软连接里哪个数据集
    TEST_IMDB="voc_0712_test"
    PT_DIR="pascal_voc"
    ITERS=110000                                    #迭代次数改大是因为07+12数据集很大
    ;;


8、改完名字还不行,因为faster rcnn只定义了2007和2012的数据集名称,并没有定义0712,所以要手动添加,py-faster-rcnn-master\lib\datasets\factory.py

# Set up voc__ using selective search "fast" mode
for year in ['2007', '2012','0712']:                      #在这个地方添加'0712'
    for split in ['train', 'val', 'trainval', 'test']:
        name = 'voc_{}_{}'.format(year, split)
        __sets[name] = (lambda split=split, year=year: pascal_voc(split, year))


9、改完这些就可以运行了,

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

你可能感兴趣的:(faster r-cnn使用Pascal VOC2007+2012联合训练)