Hi,
I'm trying to export a simple Tensorflow model and import it using opencv.dnn
inp = tf.placeholder(tf.float64, (20,3), name='input')
out = tf.matmul(inp, np.random.random((3,1)), name='output')
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
tf.saved_model.simple_save(sess, './pb', {"input": inp}, {"output": out})
tf.train.write_graph(sess.graph_def, './pbtxt', 'network.pbtxt', True)
and then I try to load it :
net = cv.dnn.readNetFromTensorflow('./pb/saved_model.pb', './pbtxt/network.pbtxt')
I get the following error:
[libprotobuf ERROR opencv/3rdparty/protobuf/src/google/protobuf/wire_format_lite.cc:629] String field 'tensorflow.GradientDef.function_name' contains invalid UTF-8 data when parsing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.
Traceback (most recent call last):
net = cv.dnn.readNetFromTensorflow('./pb/saved_model.pb', './pbtxt/network.pbtxt')
cv2.error: OpenCV(4.0.0-pre) opencv/modules/dnn/src/tensorflow/tf_io.cpp:44: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: ./pb/saved_model.pb in function 'ReadTFNetParamsFromBinaryFileOrDie'
Do you have any suggestions what might be the problem and what is the right approach to use the opencv.dnn module?
Thanks!