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

转自:https://blog.csdn.net/u012834824/article/details/78626027
我在使用代码时参考了这个博主的文章,感谢!

一、准备自己的数据库

    仅改变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中的类别

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

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

三、训练

  1. 终端训练:命令cd F R C N R O O T . / e x p e r i m e n t s / s c r i p t s / f a s t e r r c n n e n d 2 e n d . s h DEVICE D E V I C E I D V G G 16 p a s c a l v o c 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,得到结果,但不知是否正确,需要进一步验证。

猜你喜欢

转载自blog.csdn.net/wangdongwei0/article/details/81386035
今日推荐