1. 环境:Ubuntu16.04 + 1080显卡
2.所采用的程序:https://github.com/endernewton/tf-faster-rcnn
3. 数据集的更换
(1)tf-faster-rcnn/data下添加cache文件夹(空文件夹,不用放东西),imagenet_weights文件夹(存放预训练模型VGG16.ckpt),VOCdevkit2007文件夹。
(2)VOCdevkit2007文件夹下:建立三个文件夹:
annotations_cache;
results—>VOC2010—>Main;
VOC2007—>Annotations; ImageSets; JPEGImages
(3)Annotations下存放所有的标签
JPEGImages下存放所有的训练测试图片
ImageSets 下建立Main文件夹,Main下存放 test.txt; train.txt; trainval.txt; val.txt四个文件(不能缺少)
4. 修改程序
(1)lib/setup.py: 修改显卡信息
(2)tools/demo.py: class修改为自己的类别;下面TEST之后的数字21改为自己的类别数目+1
(3)lib/datasets/pascal_voc.py: 修改为自己的类别数目
5. Build the Cython modules
cd tf-faster-rcnn/lib
make clean
make
cd ..
6.Install the Python COCO API. The code requires the API to access COCO dataset
cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
cd ../../..
7.Train (and test, evaluation)
./experiments/scripts/train_faster_rcnn.sh [GPU_ID] [DATASET] [NET]
# GPU_ID is the GPU you want to test on
# NET in {vgg16, res50, res101, res152} is the network arch to use
# DATASET {pascal_voc, pascal_voc_0712, coco} is defined in train_faster_rcnn.sh
# Examples:
./experiments/scripts/train_faster_rcnn.sh 0 pascal_voc vgg16
./experiments/scripts/train_faster_rcnn.sh 1 coco res101
8.Visualization with Tensorboard
tensorboard --logdir=tensorboard/vgg16/voc_2007_trainval/ --port=7001 &
tensorboard --logdir=tensorboard/vgg16/coco_2014_train+coco_2014_valminusminival/ --port=7002 &
9.Test and evaluate
./experiments/scripts/test_faster_rcnn.sh [GPU_ID] [DATASET] [NET]
# GPU_ID is the GPU you want to test on
# NET in {vgg16, res50, res101, res152} is the network arch to use
# DATASET {pascal_voc, pascal_voc_0712, coco} is defined in test_faster_rcnn.sh
# Examples:
./experiments/scripts/test_faster_rcnn.sh 0 pascal_voc vgg16
./experiments/scripts/test_faster_rcnn.sh 1 coco res101
10. You can use tools/reval.sh
for re-evaluation
#By default, trained networks are saved under:
output/[NET]/[DATASET]/default/
#Test outputs are saved under:
output/[NET]/[DATASET]/default/[SNAPSHOT]/
#Tensorboard information for train and validation is saved under:
tensorboard/[NET]/[DATASET]/default/
tensorboard/[NET]/[DATASET]/default_val/
11. 更新了Main下的文件,重新训练时记得删除data/cache下的文件
参考:https://github.com/endernewton/tf-faster-rcnnREADME.md