Kuzushiji MNIST Classifier is a web based deployment of a deep learning convolutional neural network trained using the KMNIST Dataset. KMNIST is similar to the popular MNIST Dataset except it contains images of handwritten Japanese Hiragana characters. I am using the Kuzushiji-49 dataset which contains 270,912 images spanning 49 classes. This project contains both the development notebook detailing the creation of the CNN model, and the source code for the Flask based web app.
The model I created achieved a final balanced accuracy of about 91.3% over all of the classes. I saved this model and am using it to create class predictions from a given input file in the web app.
The app uses the JavaScript Canvas API to capture mouse or touch input from a web browser and then streams the image data back to the Flask backend where it is resized and processed into a numpy array for consumption into the Tensorflow Keras predict method of the model. The method returns an array of prediction scores, of which the greatest score is selected and matched with the character map to obtain the associated Hiragana character.
For deployment, I created a Dockerfile to build the image and a docker-compose file to create the container. The app is launched using Gunicorn and network connections are routed through the Traefik reverse proxy alongside the other services I have running on my personal server.
If you would like to deploy this app locally, follow the following steps to set up your environment and launch the Flask development server:
To launch this app on your local environment, clone this repository and change directory to the app folder:
git clone https://github.com/Kou-kun42/Kuzushiji-MNIST-Classifier.git && cd Kuzushiji-MNIST-Classifier/app
Assuming you have Python3 and pip installed, set up a python virtual environment using:
python3 -m venv env
and then activate it:
source env/bin/activate
Next, install all the required packages:
pip3 install -r requirements.txt
Finally, launch the app and navigate to the localhost endpoint on your browser:
python3 main.py