OpenCV DNN throws exception with Mask RCNN(Resnet 50) model

asked 2019-05-14 04:36:52 -0600

updated 2019-05-14 04:42:40 -0600

berak gravatar image

System information (version)

OpenCV => 4.0.0 Operating System / Platform => Ubuntu 16.04 64 Bit Compiler => gcc (5.4) Cuda 9.0 cudnn 7 Detailed description

I trained a Mask RCNN model(with Resnet50 backbone) by using a Tensorflow object detection API. I try to test the model with a C++ (OpenCV DNN) application and a c++ file(mask_rcnn.cpp)(https://github.co..., but the getConstBlob always drop this exception

~/mask-rcnn-cv$ ./mask_rcnn.out --image='/home/wangqianyun/mask-rcnn-cv/cars.jpg' ./mask_rcnn.outterminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.0.0) /home/wangqianyun/opencv/modules/dnn/src/tensorflow/tf_importer.cpp:535: error: (-2:Unspecified error) Input [FirstStageFeatureExtractor/resnet_v1_50/resnet_v1_50/block3/unit_1/bottleneck_v1/conv2/Conv2D/paddings] for node [FirstStageFeatureExtractor/resnet_v1_50/resnet_v1_50/block3/unit_1/bottleneck_v1/conv2/SpaceToBatchND] not found in function 'getConstBlob'

Steps to reproduce

  1. similiar to #13237, modify a pipeline.config file: replace height_stride: 8 weight_stride: 8

to

height_stride: 16 weight_stride: 16

  1. use tf_text_graph_mask_rcnn.py() to produce .pbtxt from .pb and .config python3 tf_text_graph_mask_rcnn_2.py --input '...../mask-rcnn-cv/mask_rcnn/frozen_inference_graph.pb' --config ...../mask-rcnn-cv/mask_rcnn/pipeline.config' --output ...../mask-rcnn-cv/mask_rcnn_elite/mask_rcnn.pbtxt

  2. compile and run g++ -std=c++11 -ggdb mask_rcnn.cpp -o mask_rcnn.out pkg-config --cflags --libs /home/wangqianyun/opencv/build/unix-install/opencv4.pc (cv) wangqianyun@wangqianyun-ThinkCentre-E73:~/mask-rcnn-cv$ ./mask_rcnn.out --image='/home/wangqianyun/mask-rcnn-cv/cars.jpg' ./mask_rcnn.out.cpp

edit retag flag offensive close merge delete