This is a Flask-based web application that allows users to upload an image of a handwritten digit (0–9), and it predicts the digit using a Convolutional Neural Network (CNN) trained on the MNIST dataset.
- Upload handwritten digit images (JPG, PNG, etc.)
- Processes the image using PIL and NumPy
- Predicts the digit using a
.kerasmodel trained on MNIST - Displays top-10 class probabilities
- Lightweight Flask backend with HTML frontend
- Saves uploaded images in a dedicated
/uploadsfolder (outside/static)
Handwritten-Digit-Recognition/
├── app.py # Main Flask application
├── digit_model.keras # Pretrained CNN model (MNIST)
├── uploads/ # Uploaded images (created dynamically)
├── templates/
│ └── index.html # HTML frontend
├── static/
│ └── style.css # Optional custom CSS
├── train_model.py # Script to train model (optional)
└── README.md
- Python 3.8+
- Flask – Web framework
- TensorFlow / Keras – Deep learning
- Pillow (PIL) – Image preprocessing
- NumPy – Array operations
pip install -r requirements.txt(Or manually install: flask, tensorflow, pillow, numpy)
Ensure digit_model.keras is in the root folder. You can use your own trained model or run train_model.py (if available).
python app.pyVisit: http://127.0.0.1:5000/
- Upload a clear image of a handwritten digit.
- App processes and resizes it to 28x28 grayscale.
- The CNN predicts the digit and shows confidence scores.
Developed by Mayank Aggarwal (Mayank-01x)
This project is licensed under the MIT License.