I am trying to create a simple python script that will allow you to put in picture of a handwritten digit and the NN model will try to make a guess as to what digit it is so far I have successfully made the model as well as tested it but when it comes to testing a single image i get an output like this.
https://i.stack.imgur.com/PQhaU.png
def make_pred():
Tk().withdraw()
filename = askopenfilename()
#the array that will hold the values of image
image = np.zeros(784)
#read image
gray = cv2.imread(filename, cv2.IMREAD_GRAYSCALE )
#resize image and set background to black
gray = cv2.resize(255-gray, (28,28))
#making the image a one dimensional array of 784
flatten = gray.flatten() / 255.0
cv2.imshow("heh",gray)
cv2.waitKey(0)
cv2.destroyAllWindows()
#saving the image and the correct value
image = flatten
prediction = neural_network_model(x)
n_save = tf.train.Saver()
with tf.Session() as sess2:
n_save.restore(sess2, './nn_test/nnmodel')
print(sess2.run(prediction,feed_dict={x: [image], y:[7]}))
The y
value is 7 because that's the digit i am trying this with.
So how do I get the value that the NN thinks the character is?