Ask Your Question

OpenCV DNN with ssd_mobilenet_v1_0.25

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

SEbert gravatar image

updated 2018-06-07 07:59:07 -0500


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:

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

2). I freezed the trained model with

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:

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 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 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-archive

edit retag flag offensive close merge delete


@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 -0500 )edit

Hi, I edited my post and uploaded a small zip-archive with my files:

the _opt.pb file is the graph after running

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

1 answer

Sort by ยป oldest newest most voted

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

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
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 51 times

Last updated: Jun 12