Faster RCNN + Tensorflow 训练自己的模型

5 篇文章 0 订阅
3 篇文章 0 订阅

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

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值