TensorFlow下用自己的数据集训练Faster RCNN

来源:互联网 发布:北京seo 按效果 编辑:程序博客网 时间:2024/05/23 02:04

一、准备自己的数据库

        仅改变VOC2007数据库的Annotation、ImageSets、JPEGImages三个文件夹。Annotation为标注文件,ImageSets为训练、测试,JPEGImages为图片。


(Faster-RCNN_TF)

二、修改原始代码

        在Tensorflow环境下实现FASTER RCNN,https://github.com/smallcorgi/Faster-RCNN_TF。

1. lib\datasets\pascal_voc.py中更改self._classes中的类别

2. lib\networks中VGGnet_train.py和VGG_test.py中更改n_classes为自己的类的个数+1

3. tools/demo.py中CLASSES的类别改为自己的类

三、训练

1. 终端训练:命令cd$FRCN_ROOT ./experiments/scripts/faster_rcnn_end2end.sh $DEVICE$DEVICE_ID VGG16 pascal_voc。 $DEVICE为GPU或CPU,$DEVICE_ID为第几块GPU,

2. Pycharm训练:在Edit Configrations中Script parameters中--cfg ../experiments/cfgs/faster_rcnn_end2end.yml  --network VGGnet_train  --device GPU  --device_id 1  --weights ../data/pretrain_model/VGG_imagenet.npy   --imdb voc_2007_trainval   --iters 70000

四、测试

        1. demo测试:

(1)在Edit Configrations中Script parameters中--model  ../model/VGGnet_fast_rcnn_iter_40000.ckpt

注:使用tensorflow 1.3跑demo出现错误 undefined symbol: _ZN10tensorflow11TensorShapeC1Ev。后改为之前使用的tensorflow版本1.2.1,demo成功跑出,是因为库不兼容

(2)终端测试: 命令cd$FRCN_ROOT  python ./tools/demo.py --model ./model/VGGnet_fast_rcnn_iter_40000.ckpt

        2. test_net测试:

(1)在Edit Configrations中Script parameters中--device gpu --device_id 0 --weights  ./model/pascal_voc/VGGnet_fast_rcnn_iter_40000.ckpt --imdb voc_2007_test --cfg  ./experiments/cfgs/faster_rcnn_end2end.yml --network VGGnet_test  

(2)终端测试: 命令python ./tools/test_net.py --device gpu --device_id 0 --weights  ./model/pascal_voc/VGGnet_fast_rcnn_iter_40000.ckpt --imdb voc_2007_test --cfg  ./experiments/cfgs/faster_rcnn_end2end.yml --network VGGnet_test  

注:在测试时出现Waiting for ./model/VGGnet_fast_rcnn_iter_40000.ckpt to exist...,因为在test_net.py中args.wait默认为True,后更改args.wait默认为False,得到结果,但不知是否正确,需要进一步验证。

参考:http://blog.csdn.net/linolzhang/article/details/70306003


阅读全文
0 0
原创粉丝点击