opencv: Import tensorflow pre-trained model using dnn modules encount an error
System information (version)
- OpenCV => 3.3.0
- Operating System / Platform => Windows 10(64 Bit)
- Compiler => Visual Studio 2015
- Tensorflow => 1.3.0
- Python => 3.6.1
Detailed description
I’ve wrote a lenet-5 model using tensorflow to train the mnist dataset, then I save the trained model file in .pb format. I use the dnn::readNetFromTensorflow() function to read the .pb file, but I get the following error:
conv1/W_conv1/RandomStandardNormal:RandomStandardNormal(conv1/W_conv1/shape)
seed:[ ]
seed2:[ ]
dtype:0
T:0
OpenCV Error: Unspecified error (Unknown layer type RandomStandardNormal in op conv1/W_conv1/RandomStandardNormal) in cv::dnn::experimental_dnn_v1::`anonymous-namespace'::TFImporter::populateNet, file C:\build\master_winpack-build-win64-vc14\opencv\modules\dnn\src\tensorflow\tf_importer.cpp, line 883
Here are my tensorflow code of “conv1/W_conv1” part:
def weight_variable(shape, name):
initial = tf.random_normal(shape, stddev=0.1, name=name)
return tf.Variable(initial)
# conv1 layer
with tf.name_scope("conv1"):
W_conv1 = weight_variable([5, 5, 1, 32], name='W_conv1')
b_conv1 = bias_variable([32], name='b_conv1')
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1, name='h_conv1')
I couldn’t find any problem in my tensorflow code, so I guess maybe my tensorflow version(released in Aug 17) is too updated for opencv 3.3.0(released in Aug 3). Hope anybody who can help me with this, thanks in advance.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (3 by maintainers)
@gorbad-6 well you can check out this link: https://github.com/TerryBryant/MyWork/tree/master/opencv_tensorflow It contains all my code
@dkurt @gorbad-6 Thank you guys, I’ve fixed this problem