Ask Your Question
1

readNet fails

asked 2019-05-06 06:10:14 -0600

LBerger gravatar image

updated 2019-05-06 07:50:46 -0600

Hi,

I'm trying to import https://github.com/yeephycho/tensorfl... model in opencv But I have this error

Message=OpenCV(4.1.0-dev) G:\Lib\opencv\modules\dnn\src\tensorflow\tf_graph_simplifier.cpp:908: error: (-215:Assertion failed) nodesMapIt != nodesMap.end() in function 'cv::dnn::dnn4_v20190430::sortByExecutionOrder' Source=openface.py StackTrace: File "openface.py", line 15, in <module> netFace = cv.dnn.readNet(path+"frozen_inference_graph_face.pb")

model is here

Stack trace :

>   opencv_dnn410d.dll!cv::dnn::dnn4_v20190430::sortByExecutionOrder(opencv_tensorflow::GraphDef & net) Line 908    C++
    opencv_dnn410d.dll!cv::dnn::dnn4_v20190430::`anonymous namespace'::TFImporter::populateNet(cv::dnn::dnn4_v20190430::Net dstNet) Line 719    C++
    opencv_dnn410d.dll!cv::dnn::dnn4_v20190430::readNetFromTensorflow(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & model, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & config) Line 1993    C++
    opencv_dnn410d.dll!cv::dnn::dnn4_v20190430::readNet(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _model, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _config, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _framework) Line 3987   C++
    ANN_Regression.exe!main() Line 120  C++

and inpName value is "BoxPredictor_0/strided_slice"

image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2019-05-07 08:36:29 -0600

LBerger gravatar image

Full recipes:

python.exe ~ \site-packages\tensorflow\python\tools\optimize_for_inference.py  --input frozen_inference_graph_face.pb --output new_frozen_inference_graph_face.pb --input_names image_tensor --output_names "num_detections,detection_scores,detection_boxes,detection_classes"  --placeholder_type_enum 4 --frozen_graph

then read this issue : copy ssd_mobilenet_v1_coco.config where is your pb file and change :

number of classes from 90 to 2 and

    image_resizer {
      fixed_shape_resizer {
        height: 300
        width: 300
      }
    }

to

    image_resizer {
      fixed_shape_resizer {
        height: 512
        width: 512
      }
    }

copy tf_text_graph_ssd.py ( and tf_text_graph_common.py) iwhere is your pb file and change line 277 (opencv4.1.-dev 20190507)

re.match('BoxPredictor_\d/BoxEncodingPredictor/Conv2D', node.name)

in

re.match('BoxPredictor_\d/BoxEncodingPredictor/convolution', node.name)

and run

tf_text_graph_ssd.py --input new_frozen_inference_graph_face.pb --output new_frozen_inference_graph_face.pbtxt --config ssd_mobilenet_v1_coco.config

edit flag offensive delete link more

Comments

1

May I ask you to propose a PR which extends regex matching for this group of layers? Thanks!

dkurt gravatar imagedkurt ( 2019-05-07 08:39:14 -0600 )edit
0

answered 2019-05-06 06:37:50 -0600

dkurt gravatar image

It looks like a model created with TensorFlow Object Detection API. Do you have a .configfile? See https://github.com/opencv/opencv/wiki... for details.

edit flag offensive delete link more

Comments

I tried Try to run optimize_for_inference.py tool to make your model simpler: no change

About Try fuse constant nodes by a graph transformation tool. I haven't got this on my computer. How can I get it ?

LBerger gravatar imageLBerger ( 2019-05-06 10:03:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-05-06 06:10:14 -0600

Seen: 2,994 times

Last updated: May 07 '19