This project demonstrates handwritten digit recognition using a Convolutional Neural Network (CNN) trained on the MNIST dataset.
digit_recognition_model.py
: Trains a CNN on MNIST and saves the model as .h5
digit_recognition_model.h5
: Trained model fileprediction.py
: Loads the saved model and predicts digits from uploaded images (28x28 grayscale)Run the training script if you want to retrain the model:
python digit_recognition_model.py
This will create digit_recognition_model.h5
.
To predict digits from new images:
python prediction.py
You will be prompted to upload an image (must be 28x28 pixels, grayscale). The script will output the predicted digit along with a plot.
Tip: Use Google Colab if youβre facing hardware limitations.
The user provides a 28x28 grayscale image of a handwritten digit:
The model predicts the digit with high accuracy:
Install with:
pip install tensorflow numpy matplotlib pillow
This project uses the MNIST dataset, which is built into TensorFlow.
This project is open-source and free to use under the MIT License.