Ask Your Question
0

OpenCV DNN with ssd_mobilenet_v1_0.25

asked 2018-06-07 07:20:56 -0600

SEbert gravatar image

updated 2018-06-07 07:59:07 -0600

Hi,

I try to run ssd_mobilenet_v1_0.25 with OpenCV DNN. The wet was trained by the Tensorflow object detection API.

In the forward step in C++ (cv::Mat output = m_net.forward();), I get following errror:

OpenCV Error: Assertion failed (!_aspectRatios.empty(), _minSize > 0) in cv::dnn::PriorBoxLayerImpl::PriorBoxLayerImpl, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\layers\prior_box_layer.cpp, line 207

I did follow this article: https://github.com/opencv/opencv/wiki...

1). I trained my model with TF object detection API

2). I freezed the trained model with

py export_inference_graph.py --input_type image_tensor --pipeline_config_path training/ssd_mobilenet_v1.config --trained_checkpoint_prefix training/model.ckpt-14623 --output_directory inference_graph

3). constructed pbtxt file with: tf_text_graph_ssd.py

4.) At this stage I tried to read in the pb-file in C++:

m_net = cv::dnn::readNetFromTensorflow(sPathToTensorflowModel_PB, sPathToTensorflowModel_PBTXT);

--> Exception: Could not load the net

5.) Thus I followed the trouble shooting section and used optimize_for_inference.py on my frozen_inference_graph.pb and re-constructed the pbtxt file on the optimized file see 3.) After this, I re-tried 4.), which was successful. But now the forward cv::Mat output = m_net.forward(); gives an exception (see error shown above).

I already successfully loaded and forwarded the ssd_mobilenet_v1 with depth_multiplier=1.0 in openCV dnn. The ssd_mobilenet_v1_0.25 = ssd_mobilenet_v1 with depth_multiplier 0.25 trains and inferences (forwards) successfully in tensorflow (tested with the object_detection_tuorial.py script)

Any suggestions, how to build a valid pbtxt file for the 25% ssd_mobilenet_v1? Any help is greatly appreciated.

Edit: Attached my .config and pb/pbtxt files in a zip-archivehttps://ufile.io/0ntdf

edit retag flag offensive close merge delete

Comments

@SEbert, you can make it more easier if you will share a reference to serialized .pb graph.

dkurt gravatar imagedkurt ( 2018-06-07 08:19:07 -0600 )edit

Hi, I edited my post and uploaded a small zip-archive with my files: https://ufile.io/0ntdf

the _opt.pb file is the graph after running optimize_for_inference.py

SEbert gravatar imageSEbert ( 2018-06-07 08:22:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-12 01:53:07 -0600

SEbert gravatar image

I solved my problem by a custom build of the current openCV master branch, including the contrib-master. It works very fine, but be warned, building OpenCV from source is not that easy.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-07 07:20:56 -0600

Seen: 808 times

Last updated: Jun 12 '18