Ask Your Question

Revision history [back]

OpenCV and inception Tensorflow model c++

Hello,

I have trained a neural network based on inception v3 from the tensorflow tutorial (https://www.tensorflow.org/hub/tutorials/image_retraining). The network works with tensorflow in c ++ without problems.

I'm trying to load it with OpenCV 4.0 beta. The network is loaded correctly (I use the .pb file) with:

net = cv :: dnn :: readNetFromTensorflow (model);

The problem appears when I do the .forward with an input image, an exception occurs:

Error: Unspecified error (Can not create layer "input / BottleneckInputPlaceholder" of type "PlaceholderWithDefault") in cv :: dnn :: dnn4_v20180917 :: LayerData :: getLayerInstance, file c: \ build \ master_winpack-build-win64-vc15 \ opencv \ modules \ dnn \ src \ dnn.cpp, line 412

The network entry layer (placeholder) needs the following format  type: float32 [?, 299,299.3]

In all the examples I have seen that the input blob is created with cv :: dnn :: blobFromImage.

I am using this call: cv :: dnn :: blobFromImage (img, blob, 1.0f / 255.0f, Size (299, 299), Scalar (), true, false);

The blob that generated this call is {FLOAT32, 1 x -1 x -1}, which seems clear that it is not what the network's input layer expects.

Please I need help.

Thanks in advance.

click to hide/show revision 2
retagged

updated 2018-11-13 03:32:31 -0600

berak gravatar image

OpenCV and inception Tensorflow model c++

Hello,

I have trained a neural network based on inception v3 from the tensorflow tutorial (https://www.tensorflow.org/hub/tutorials/image_retraining). The network works with tensorflow in c ++ without problems.

I'm trying to load it with OpenCV 4.0 beta. The network is loaded correctly (I use the .pb file) with:

net = cv :: dnn :: readNetFromTensorflow (model);

The problem appears when I do the .forward with an input image, an exception occurs:

Error: Unspecified error (Can not create layer "input / BottleneckInputPlaceholder" of type "PlaceholderWithDefault") in cv :: dnn :: dnn4_v20180917 :: LayerData :: getLayerInstance, file c: \ build \ master_winpack-build-win64-vc15 \ opencv \ modules \ dnn \ src \ dnn.cpp, line 412

The network entry layer (placeholder) needs the following format  type: float32 [?, 299,299.3]

In all the examples I have seen that the input blob is created with cv :: dnn :: blobFromImage.

I am using this call: cv :: dnn :: blobFromImage (img, blob, 1.0f / 255.0f, Size (299, 299), Scalar (), true, false);

The blob that generated this call is {FLOAT32, 1 x -1 x -1}, which seems clear that it is not what the network's input layer expects.

Please I need help.

Thanks in advance.