OpenCV and inception Tensorflow model c++

asked 2018-11-13 03:28:03 -0600

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

berak gravatar image

Hello,

I have trained a neural network based on inception v3 from the tensorflow tutorial (https://www.tensorflow.org/hub/tutori...). 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.

edit retag flag offensive close merge delete

Comments

1

May be this post will help you

LBerger gravatar imageLBerger ( 2018-11-13 03:55:51 -0600 )edit

Thank you very much, I'm already classifying. Now I have to see why it does not give the same classification values with OpenCV vs. Tensorflow API directly.

SpFloppy gravatar imageSpFloppy ( 2018-11-14 04:08:51 -0600 )edit