A real-time handwritten digit recognition desktop application built with Java and JavaFX, powered by a TensorFlow-trained CNN model.
Draw any digit (0–9) on the canvas, click Recognize, and get an instant prediction with confidence score.
- Java / JavaFX — GUI and drawing canvas
- TensorFlow + Python — CNN model training on MNIST dataset
- ONNX Runtime — Model inference in Java
- Maven — Dependency management
- Java 23
- Maven (install via Homebrew:
brew install maven)
- Clone the repository
- Navigate to the project folder:
cd NumberRecognizer- Run the application:
mvn javafx:runA CNN trained on MNIST (99.34% test accuracy), served in Java:
Training (Python) → ONNX export → Inference (Java, ONNX Runtime)
The TensorFlow SavedModel couldn't run in Java on Apple Silicon due to native library incompatibility, so the model is exported to ONNX — decoupling the training stack from the serving stack.
Canvas input is preprocessed before inference: bounding-box detection → centering → 28×28 grayscale, matching MNIST's input format.
Main.java— Application entry pointMainController.java— UI logic and mouse drawingPredictor.java— Model inference and image preprocessingModelLoader.java— Model loading from resources