Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try to use the master branch of OpenCV. I cannot reproduce the problem.

graph = 'without_dropout.pb'
cvNet = cv.dnn.readNet(graph)

with tf.gfile.FastGFile(graph) as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    print graph_def.node[0]
    print graph_def.node[-1]

with tf.Session() as sess:
    sess.graph.as_default()
    tf.import_graph_def(graph_def, name='')

    np.random.seed(234)
    inp = np.random.standard_normal([1, 250, 250, 1]).astype(np.float32)
    out = sess.run(sess.graph.get_tensor_by_name('Dense2/output_node:0'),
                   feed_dict={'input_node:0': inp})

    cvNet.setInput(inp.transpose(0, 3, 1, 2))
    cvOut = cvNet.forward()

    print np.max(np.abs(cvOut - out))

outputs 2.9802322e-07.