1

I have trained a KNN model to predict handwritten images in the MNIST dataset. I want to test it on my own handwriting now. I want to convert it into the MNIST format (values for 784 pixels in the image as an array). I tried converting the image into a 28*28 pixels and storing the pixel intensities in the code below:

img = cv2.imread(image,cv.IMREAD_GRAYSCALE)
resized = cv2.resize(img, (28,28)) 
features = resized.reshape(1,-1)

But foir some reason it is not working and the predictions are always '0'. I think I will need to shift my own image to the center of 28x28 image and grayscale it. I also think my image is not being converted into the array properly.

Aryagm
  • 530
  • 1
  • 7
  • 18

0 Answers0