Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Segmentation fault on readNetFromTensorflow

I'm currently trying to create a .pb file for the InceptionV3 that runs on OpenCV 3.3. The problem is that, even after using the prepare_for_dnn.py script I'm not able to load it using readNetFromTensorflow and I have no idea why.

I managed to create a .pbtxt file for this checkpoint available on the internet, and I packaged all files (ckpt, pbtxt and my pb) in here: https://drive.google.com/open?id=0BwyxoBTUAvyZU3dyNDRhdXJvbG8

To create the pb using the ckpt and pbtxt, I ran the following command:

export TENSORFLOW=/path/to/tensorflow
python prepare_for_dnn.py -frz $TENSORFLOW/tensorflow/python/tools/freeze_graph.py -opt $TENSORFLOW/tensorflow/python/tools/optimize_for_inference.py -tr $TENSORFLOW/bazel-bin/tensorflow/tools/graph_transforms/transform_graph -net inception.pbtxt -ckpt inception_v3.ckpt -in_node Placeholder -out_node InceptionV3/Logits/AvgPool_1a_8x8/AvgPool -o inception-v3.pb

Then, I tried to load the model with this code:

#include <iostream>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

using namespace cv;
using namespace cv::dnn;
using namespace std;

int main(int argc, char **argv) {
    dnn::Net net = readNetFromTensorflow("inception-v3.pb");
}

but I'm getting segmentation fault. From gdb I get the following message:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff766baf0 in cv::dnn::experimental_dnn_v1::(anonymous namespace)::TFImporter::populateNet(cv::dnn::experimental_dnn_v1::Net) ()
   from /usr/local/lib/libopencv_dnn.so.3.3

Anyone faced a similar problem? Thanks in advance for any help!