- Author: Timothée Blanpied
- Created: 2023/08
- Live Demo: https://digit.demo.blanpied.fr/
DigitRecognition is a small TensorFlow/Keras project that trains a convolutional neural network (CNN) on the MNIST dataset and provides a simple web-based drawing interface to make live digit predictions.
This project contains a training notebook and a lightweight web UI that lets users draw digits in the browser and get realtime predictions from a pre-converted TensorFlow.js model.
- Trains a CNN on the MNIST handwritten digits dataset (training implemented in
DigitRecognition.ipynb). - Exposes a web drawing interface in the
interface/folder where users can draw digits and see live predictions.
- Python 3.8+
- TensorFlow / Keras
- TensorFlow.js (for the browser model)
- Numpy, Pandas, Matplotlib, ImageIO
- A tiny HTTP server to serve the interface (
interface/server.py)
- Start the server with
python3 server.py. (You must be insideinterface) - Draw a digit in the canvas.
- The frontend will load the TF.js model (if present) and display the predicted digit.
-
Create and activate a virtual environment (recommended):
python3 -m venv .venvsource .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Dataset placement:
- Place the MNIST image files and
labels.csvunderdataset/mnist/(this project expectsdataset/mnist/labels.csv).
- Place the MNIST image files and
-
Train the model (optional):
- Open
DigitRecognition.ipynbin Jupyter and run the cells to preprocess data, train the CNN, and export a TensorFlow.js model.
- Open
-
Run the web interface locally (serves
interface/at http://localhost:8000):python3 server.pyThen open your browser at
http://localhost:8000.
- The interface expects a TensorFlow.js model (model.json + weights files). If you have a converted TF.js model, place it in
interface/model/or updateinterface/index.jsto point to the model location.
See the included LICENSE file.
If you have questions, open an issue or contact the repository owner.
