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 FRCNROOT./experiments/scripts/fasterrcnnend2end.sh 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 DEVICEIDVGG16pascalvoc 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,得到结果,但不知是否正确,需要进一步验证。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值