Skip to content

This project implements a Convolutional Neural Network (CNN) to recognize handwritten digits using the MNIST dataset. The model is built using TensorFlow and Keras, trained on grayscale images (28x28), and saved as an .h5 file for future predictions. Users can input their own digit images and receive real-time predictions using the provided script.

License

Notifications You must be signed in to change notification settings

Harini1305/handwritten-digit-recognition

Repository files navigation

🧠 Handwritten Digit Recognition with CNN

This project demonstrates handwritten digit recognition using a Convolutional Neural Network (CNN) trained on the MNIST dataset.

🚀 Project Structure

  • digit_recognition_model.py: Trains a CNN on MNIST and saves the model as .h5
  • digit_recognition_model.h5: Trained model file
  • prediction.py: Loads the saved model and predicts digits from uploaded images (28x28 grayscale)

🛠️ How to Run

1. Training the Model

Run the training script if you want to retrain the model:

python digit_recognition_model.py

This will create digit_recognition_model.h5.

2. Making Predictions

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.

🧪 Example

🔤 Input Image

The user provides a 28x28 grayscale image of a handwritten digit:

Input Digit

✅ Predicted Output

The model predicts the digit with high accuracy:

Predicted Digit

🧰 Requirements

  • TensorFlow
  • NumPy
  • matplotlib
  • PIL (Pillow)

Install with:

pip install tensorflow numpy matplotlib pillow

📦 Dataset

This project uses the MNIST dataset, which is built into TensorFlow.

📜 License

This project is open-source and free to use under the MIT License.

About

This project implements a Convolutional Neural Network (CNN) to recognize handwritten digits using the MNIST dataset. The model is built using TensorFlow and Keras, trained on grayscale images (28x28), and saved as an .h5 file for future predictions. Users can input their own digit images and receive real-time predictions using the provided script.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages