Opencv maskrcnn(四)opencv调用maskrcnn模型

本文档详细介绍了如何将ckpt模型转换为.pb文件,生成.pbtxt文件,配置mscoco_labels.names和colors.txt,最后在OpenCV中调用Mask R-CNN进行实例检测,虽然CPU运行速度较慢(约8s/张),但为GPU加速留出了后续研究的空间。
摘要由CSDN通过智能技术生成

1 目录结构

接着上一小节继续做,在log文件夹中新建out文件夹。
在这里插入图片描述

2 ckpt转pb文件

上一节中num_steps = 200,当设置num_steps = 200000时
在这里插入图片描述

cd C:\Users\Administrator\Desktop\Tensorflow\ObjectDetection\models\research\object_detection
python export_inference_graph.py --input_type=image_tensor --pipeline_config_path="C:/Users/Administrator/Desktop/opmask/mask/mask_rcnn_inception_v2_coco_2018_01_28/mask_rcnn_inception_v2_coco.config" --trained_checkpoint_prefix="C:/Users/Administrator/Desktop/opmask/mask/log/model.ckpt-200000" --output_directory="C:/Users/Administrator/Desktop/opmask/mask/log/out"

3 生成pbtxt文件

找到opencv中sources/samples/dnn模块中tf_text_graph_mask_rcnn.py,复制并重命名为tf_text_graph_mask_rcnn_me.py,修改文件中的下述路径。
parser.add_argument('--input', default='C:/Users/Administrator/Desktop/opmask/mask/log/out/frozen_inference_graph.pb', help='Path to frozen TensorFlow graph.')
parser.add_argument('--output', default='C:/Users/Administrator/Desktop/opmask/mask/log/out/mask_rcnn.pbtxt', help='Path to output text graph.')
parser.add_argument('--config', default='C:/Users/Administrator/Desktop/opmask/mask/mask_rcnn_inception_v2_coco_2018_01_28/mask_rcnn_inception_v2_coco.config', help='Path to a *.config file is used for training.')
args = parser.parse_args()
cd C:\Users\Administrator\Desktop\opencv4\opencv\sources\samples\dnn
python tf_text_graph_mask_rcnn_me.py

4 mscoco_labels.names

0.0
0.4
0.8
1.2
1.6
point
<
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值