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.h5digit_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.pyThis will create digit_recognition_model.h5.
To predict digits from new images:
python prediction.pyYou 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:
- TensorFlow
- NumPy
- matplotlib
- PIL (Pillow)
Install with:
pip install tensorflow numpy matplotlib pillowThis project uses the MNIST dataset, which is built into TensorFlow.
This project is open-source and free to use under the MIT License.

