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

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

export TENSORFLOW=/path/to/tensorflow
python -frz $TENSORFLOW/tensorflow/python/tools/ -opt $TENSORFLOW/tensorflow/python/tools/ -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/

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