Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using readNetFromTensorflow() and running Frozen Graph, but Fails to predict correctly

I have a frozen graph that im trying to load into opencv 3.3 dnn in python. The graph works as I have loaded it separately using tf.import_graph_def() and predicts correctly. Opencv on the other hand runs the model but predicts completely wrong. I know that the function in opencv uses mean subtraction which i have tried both of all images and the input image mean BGR value, but it does not seem to help me. Any help would be greatly appreciated.

Thanks

example code:

# read the testing data
test_data = np.load('../test_data.npy')

X = np.array([i[0] for i in test_data]).reshape(-1, 125, 50, 3)
Y = [i[1] for i in test_data]

mean = np.mean(X[2398], axis=( -2, -3))

blob = cv2.dnn.blobFromImage(X[2398], 1, (125, 50), mean)

net.setInput(blob, name="input/X")

start = time.time()

preds = net.forward(outputName="output_layer/Softmax")

end = time.time()

print("[INFO] classification took {:.5} seconds".format(end - start))