The Handwritten Digit Classifier is a cross-platform mobile application to capture and classify handwritten digits. The application leverages Google's mobile UI framework, Flutter, and is completely written in the Dart programming language. A few Dart packages are used to ease cross-platform resource management:
- camera (BSD) - A Flutter plugin for iOS and Android allowing access to the device cameras.
- tflite (MIT) - A Flutter plugin for accessing TensorFlow Lite API. Supports Classification and Object Detection on both iOS and Android.
- path_provider (BSD) - A Flutter plugin for finding commonly used locations on the filesystem. Supports iOS and Android.
- image (Apache 2.0) - A Dart library providing the ability to load, save and manipulate images in a variety of different file formats.
See LICENSE file.
- For best results, write a digit with black marker on a white piece of paper.
- Black or blue pen may work as well, but will likely need to be traced multiple times
- Launch the "Handwritten Digit Classifier" application
- Press the floating camera button to launch the camera
- You may need to read and accept and camera permissions prompts
- With sufficient lighting, center the written digit from step 1 onto the screen so that it is centered and takes up roughly 80% of the preview window.
- Capture the digit with the camera by pressing the blue circle button at the bottom of the application screen.
- Await the classification processing.
- View the top classification result on the screen for each image previously captured.
- Repeat!
- Maintains scrolling list of all images taken and the classification results.
- The captured image is rescaled to the size inputted into the neural network and displayed on screen.
- The classification results indicate the digit recognized and the confidence (a probability in the range [0, 1]) of the recognition.
- Allows user to easily capture unique input via the device camera.
- Leverages artificial intelligence (AI) through the use of a neural network model built in TensorFlow in order to classify input images.
- The neural network model is trained on a variant of the MNIST handwriten digit database in order to improve ease of deployment and real-world accuracy within a mobile device. See my notebook for more details.
- Pixel values are normalized from [0, 255] to [0, 1]
- Gaussian noise
N(0.3, 0.1)
is added to background pixels and thresholded to [0, 1] - Colors are inverted for black writing on white background
- Minimum Android SDK version of 21, target of 28 for best results.
flutter build apk
- To build and Android APK file.flutter build ios
- To build an iOS application bundle (Mac OS X only).flutter run
- To run on an attached device.