The Handwritten Digit Recognition System is a machine learning application that identifies and classifies handwritten digits (0-9) using a trained deep learning model. This project leverages TensorFlow/Keras and a Convolutional Neural Network (CNN) to achieve high accuracy in recognizing handwritten digits from images.
- Digit Classification: Identifies digits from 0 to 9.
- High Accuracy: Utilizes a CNN model for precise predictions.
- Streamlined Model Loading: Efficiently loads the pre-trained model for real-time predictions.
- Ease of Use: Simple and intuitive Python implementation.
- Python 3.8+
- TensorFlow 2.8+
- NumPy
- Matplotlib (optional, for visualizations)
- Streamlit (optional, for building a web interface)
- Clone the repository:
git clone <repository_url> cd handwritten_digit_recognition
- Install dependencies:
pip install -r requirements.txt
- (Optional) Install Streamlit for a web interface:
pip install streamlit
-
Run Predictions with Python Script:
python app.py
Replace
digit_recognition_model.keras
with your model file if needed. -
Input Image for Prediction:
- Provide an image containing a handwritten digit (28x28 grayscale).
- The model will output the predicted digit with its confidence score.
-
Run Streamlit App (if implemented):
streamlit run app.py
- Architecture: Convolutional Neural Network (CNN) with multiple layers, including convolutional, pooling, and dense layers.
- Dataset: Trained on the MNIST dataset, which contains 60,000 training and 10,000 testing images of handwritten digits.
- Input Shape: 28x28 grayscale images.
- Output: A single digit (0-9).
Here is an example of how the system predicts a digit:
import tensorflow as tf
import numpy as np
# Load the model
model = tf.keras.models.load_model('digit_recognition_model.keras')
# Load and preprocess an image
image = np.zeros((28, 28)) # Example input image
image = image.reshape(1, 28, 28, 1) / 255.0 # Reshape and normalize
# Make a prediction
prediction = model.predict(image)
predicted_digit = np.argmax(prediction)
print(f"Predicted Digit: {predicted_digit}")
- Add support for multi-digit recognition.
- Enhance GUI/UX for a web-based interface.
- Extend support for datasets beyond MNIST.