opencv: Error loading faster rcnn using opencv
System information (version)
OpenCV => 3.4.3.18
Operating System / Platform => Windows 10 64 Bit
TensorFlow=> 1.11.0
Detailed description
I trained a faster_rcnn_resnet50 model with 1 class (using the faster_rcnn_resnet50_coco.config) and when I tried to load the network using readnetfromtensorflow
, I got the following error:
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:495: error: (-2:Unspecified error) Input layer not found: CropAndResize/Reshape/shape in function ‘cv::dnn::experimental_dnn_34_v7::`anonymous-namespace’::TFImporter::connect’
I generated the pbtxt file through tf_text_graph_faster_rcnn.py
and also tried generating one after optimize_for_inference.py
, but none of them worked out. Need help to fix this! Thanks in advance.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (12 by maintainers)
@plin24, the following experiment gives relatively similar outputs:
Modify
to_remove
method attf_text_graph_faster_rcnn.py
. And generate a.pbtxt
file.from
to
Open resulting
.pbtxt
file and find a node with nameMaxPool2D/MaxPool
(it should has no inputs). Add a single input for it:Then remove nodes with the following names:
Replace one of Reshape nodes to Flatten:
from
to
Using the following script I can receive pretty similar results
TensorFlow:
OpenCV:
As you may see one of objects is missed. However the rest of them are predicted correctly. Please give us more time to figure out what the problem is.
@dkurt this is a test image https://github.com/priya-dwivedi/Deep-Learning/blob/master/Custom_Mask_RCNN/test_images/image1.jpg and result https://drive.google.com/drive/u/1/folders/1N6-_aIIu6CfBnzqr5Sw7sOn8_ValvUHD
@dkurt Thank you so much for solving this issue and good luck on fixing the error!