Opencv_contrib: DNN Single Shot MultiBox Detector (SSD) Execution Errors

Created on 5 Jan 2017  Â·  8Comments  Â·  Source: opencv/opencv_contrib

System information (version)
  • OpenCV => 3.2
  • Operating System / Platform => Windows 8 Pro 64 Bit
  • Compiler => Visual Studio 2013
Detailed description

  • Unable to run SSD models on the OpenCV3.2 SSD sample code
  • Attempted on two different .prototxt files:
  • The deploy.prototxt that comes with the download (PASCAL VOC 07+ 12 SSD300)
    The error is on a missing field named "norm_param"
[libprotobuf ERROR C:\opencv320\build\modules\dnn\3rdparty\protobuf\sources\prot
obuf-3.1.0\src\google\protobuf\text_format.cc:298] Error parsing text-format caf
fe.NetParameter: 817:14: Message type "caffe.LayerParameter" has no field named
"norm_param".
OpenCV Error: Unspecified error (FAILED: ReadProtoFromTextFile(param_file, param
). Failed to parse NetParameter file: C:\Users\REG-LPT-038\Documents\SSD Models\
V2\deploy.prototxt) in cv::dnn::ReadNetParamsFromTextFileOrDie, file C:\opencv32
0\opencv_contrib320\modules\dnn\src\caffe\caffe_io.cpp, line 1101
C:\opencv320\opencv_contrib320\modules\dnn\src\caffe\caffe_io.cpp:1101: error: (
-2) FAILED: ReadProtoFromTextFile(param_file, param). Failed to parse NetParamet
er file: C:\Users\REG-LPT-038\Documents\SSD Models\V2\deploy.prototxt in functio
n cv::dnn::ReadNetParamsFromTextFileOrDie
  1. The OpenCV3.2 sample .prototxt VGG_VOC0712_SSD_300x300_iter_60000.prototxt
    The following error is asserted at net.forward();
OpenCV Error: Assertion failed ((bias && l->blobs.size() == 2) || (!bias && l->b
lobs.size() == 1)) in cv::dnn::initConvDeconvLayerFromCaffe, file C:\opencv320\o
pencv_contrib320\modules\dnn\src\caffe\layer_loaders.cpp, line 27
OpenCV Error: Assertion failed (The following error occured while making allocat
e() for layer "pool6_mbox_loc": (bias && l->blobs.size() == 2) || (!bias && l->b
lobs.size() == 1)) in cv::dnn::initConvDeconvLayerFromCaffe, file C:\opencv320\o
pencv_contrib320\modules\dnn\src\caffe\layer_loaders.cpp, line 27
  • Side info for the test image fed:
Type of file: PNG
Size: 666KB
Dimensions: 1024x578
Bit depth: 24
Steps to reproduce


After successfully compiling the OpenCV3.2 [SSD sample code],

  • Run by populating the command arguments (On the different .prototxt):
  • The deploy.prototxt that comes with the download (PASCAL VOC 07+ 12 SSD300)
SSD.exe -proto="C:\Users\REG-LPT-038\Docume
nts\SSD Models\V2\deploy.prototxt" -model="C:\Users\REG-LPT-038\Documents\
SSD Models\V2\VGG_VOC0712_SSD_300x300_iter_120000.caffemodel" -image="E:\vlc
snap-2016-11-07-10h08m20s920.png" -min_confidence="0.7"
  1. The OpenCV3.2 sample .prototxt VGG_VOC0712_SSD_300x300_iter_60000.prototxt
SSD.exe -proto="C:\opencv320\opencv_contrib320\modules\dnn\samples\
VGG_VOC0712_SSD_300x300_iter_60000.prototxt" -model="C:\Users\REG-LPT-038\Docume
nts\SSD Models\V2\VGG_VOC0712_SSD_300x300_iter_120000.caffemodel" -image="E:\vlc
snap-2016-11-07-10h08m20s920.png" -min_confidence="0.7"

Any advice is greatly appreciated.
Thank you.

invalid

Most helpful comment

Hi, the library works actually. It's just that they seem to not support some of the parameters and uses different layer type names.

A quick check on www.diffchecker.com between the supplied prototxt example and any of the downloaded model from the SSD author will let you know what to change.

If my memory serves me well, you will have to change "Normalize" to "NormalizeBBox", norm_param to normalize_bbox_param, remove all step and offset, and also amend the detection_output_param in the last layer.

Good luck!

All 8 comments

I have managed to come up with a solution by comparing the deploy.prototxt with the OpenCV3.2 prototxt and then apply the changes accordingly.

P.S. Thank you for the awesome work on the library!

I meet the same problem.Could you help me?how to change the prototxt.
Thank you.

I got it,too!
It is different name for the same param!
normalize_bbox_param==norm_param

Wow, thanks for integration!

I meet such problem ether, but how to change the prototxt in detail?
I am new to caffe and I felt excited when I knew OpenCV supports SSD nevertheless it doesn't work.

Hi, the library works actually. It's just that they seem to not support some of the parameters and uses different layer type names.

A quick check on www.diffchecker.com between the supplied prototxt example and any of the downloaded model from the SSD author will let you know what to change.

If my memory serves me well, you will have to change "Normalize" to "NormalizeBBox", norm_param to normalize_bbox_param, remove all step and offset, and also amend the detection_output_param in the last layer.

Good luck!

It works amazingly! Thank you so much!

Leaving the modified file here for anyone else facing this issue.
deploy.txt

You can rename this file to deploy.prototxt and use the following command:
./example_dnn_ssd_object_detection --image=./rgb_frame40.png --model=VGG_VOC0712_SSD_300x300_iter_120000.caffemodel --proto=deploy.prototxt --min_confidence=0.5

Was this page helpful?
0 / 5 - 0 ratings