Skip to content

ADITYASHAH-IITP/HandWritten_Digit_Recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

HandWritten_Digit_Recognition

MNIST Handwritten Digit Recognition



The MNIST dataset is an acronym that stands for the Modified National Institute of Standards and Technology dataset. It is a dataset of 60,000 small square 28×28 pixel grayscale images of handwritten single digits between 0 and 9. The task is to classify a given image of a handwritten digit into one of 10 classes representing integer values from 0 to 9, inclusively.





Each image is 28 pixels in height and 28 pixels in width, for a total of 784 pixels in total. Each pixel has a single pixel-value associated with it, indicating the lightness or darkness of that pixel, with higher numbers meaning darker. This pixel-value is an integer between 0 and 255, inclusive.

#Results

image


Model can saved by -->
model.save('Model.h5')
The model can be loaded via the load_model() function.
from tensorflow.keras.models import load_model

load and prepare the image

from keras.preprocessing.image import img_to_array
def load_image(filename):
# load the image
img = load_img(filename, grayscale=True, target_size=(28, 28))
# convert to array
img = img_to_array(img)
# reshape into a single sample with 1 channel
img = img.reshape(1, 28, 28, 1)
# prepare pixel data
img = img.astype('float32')
img = img / 255.0
return img

load an image and predict the class


img = load_image('Sample.png')
# load model
model = load_model('Model.h5')
# predict the class
predict_value = model.predict(img)
digit = argmax(predict_value)
print(digit)
---