Object Detection API(3)—— 训练自己的模型

Object Detection API(3)—— 训练自己的模型

https://blog.csdn.net/qq_34106574/article/category/7628923 

   由上一节的数据组织结果,可以得到自定义数据的record格式,my.record,my-val.record.本节对相应的配置文件进行修改,使用自定义record数据进行模型训练。

1,训练过程:

 (1)首先选择并下载一个预训练的模型,这里选择faster_rcnn_resnet101_coco_2017_11_08文件,建立目录如下:

 

(2)从G:\git\models-master\research\object_detection\samples\configs

复制faster_rcnn_resnet101_coco.config配置文件到你的工程目录下,修改此配置文件如下:

 

(3)编辑my_label_map.pbtxt如下:

        

(4)运行训练脚本如下:

python ../research/object_detection/train.py --logtostderr --train_dir=train/ --pipeline_config_path=train/faster_rcnn_resnet101_coco.config

(5)最终训练结果如下:

2,测试过程:

(1)参照上一章节生成out.record的方式生成my_val.record,或直接使

用训练时的my.record.

(2)运行训练脚本如下:

   python ../research/object_detection/eval.py --logtostderr --pipeline_config_path=train/faster_rcnn_resnet101_coco.config --checkpoint_dir=train/ --eval_dir=val/

(3)运行:tensorboard --logdir val

(4)最终测试结果如下:

 

3,训练及测试过程遇到的问题:

E1:

File"/home/usr/models/research/object_detection/utils/dataset_util.py", line 128, in read_dataset tf.contrib.data.parallel_interleave(AttributeError: 'module' object has no attribute 'parallel_interleave'

解决方法:这个问题貌似是版本不兼容的问题,需要升级tensorflow的版本,我的是1.4的,可以升级到1.6,命令如下:

pip install tensorflow-gpu==1.6.0

E2:

obj detection training with faster_rcnn_inception_v2_coco Argument must be a dense tensor: range(0, 3) - got shape [3], but wanted [].

解决方法:此错误是python3的不兼容问题,可以修改models/research/object_detection/utils/learning_schedules.py文档的 167-169行如下:

修改前:

rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),

                                      range(num_boundaries),

                                      [0] * num_boundaries))

修改后:

rate_index = tf.reduce_max(tf.where(tf.greater_equal(global_step, boundaries),

                                     list(range(num_boundaries)),

                                      [0] * num_boundaries))

E3:

测试阶段错误ImportError: No module named 'pycocotools'

解决方法:

Linux中运行:pip install git+https://github.com/waleedka/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI

Windows中运行: pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

 

 

参考资料

[1] https://github.com/tensorflow/models/issues/3565

[2] https://github.com/tensorflow/models/issues/3705#issuecomment-375563179

[3] https://github.com/matterport/Mask_RCNN/issues/6

 

注:更多内容分享及源码获取欢迎关注微信公众号:ML_Study

 

版权声明:本文为博主原创文章,转载请联系作者取得授权。https://blog.csdn.net/qq_34106574/article/category/7628923 

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arthur.AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值