This application predicts the handwritten Kannada character using a pretrainet ResNet18 model. You can use the basic web app to draw the character on a sketchpad and get the prediction.
For this model, I have used the Kannada handwritten characters from the Chars74k Dataset.
The dataset contains 657 classes and 25 images from each class(not a lot).
Highly recommend a NVIDIA GPU in order to use this project, but will work on a CPU too. The program will run a lot slower when using CPU.
This project only works on Linux.(The fastai library only runs on Linux)
Recommend downloading all the below requirements using conda package manager which comes with Anaconda or Miniconda (Light version of Anaconda).
Python 3.6 and any greater version(Comes by default along with Anaconda).
The following lines contain required libraries and how to install them (Some of the packages below come by default with Anaconda) -
-
fastai v1
$ conda install -c fastai fastai
-
Numpy
$ conda install -c anaconda numpy
-
PyTorch
PyTorch is installed along with fastai when it is installed with conda.
-
Flask
$ conda install -c anaconda flask
-
Pillow
$ conda install -c anaconda pillow
-
Jupyter Notebooks
$ conda install -c anaconda notebook
Other optional requirements -
Sklearn
$ conda install -c anaconda scikit-learn
After installing the packages type the following command in order to update all the packages.
$ conda update --all
- Download the Kannada Handwritten Images Datatset from the above link and extract the data from the zip file to current directory.
- Open
jupyter notebook
and run theData Preparation.ipynb
file to make the data ready for training the model. - Make sure the
data
directory andlabels.csv
file is created.
Please run the above Training and Validation Data Preparation steps before training the model.
- After preparing the data, open
jupyter notebook
and run theKannada Character Recognition.ipynb
. - The models saved in the notebook will be stored by default in a
models
directory. - I have used a ResNet18 model architecture, using a bigger ResNet like ResNet34 etc might improve accuracy as well as F1 score.
Please run the above Training and Validation Data Preparation as well as Training the Model steps before running the web app.
-
Run the
create_classes_folder.py
.$ python3 create_classes_folder.py
-
Open a terminal in the
webapp
directory and runapp.py
$ python3 app.py
This will start the flask server and the application can be used by opening the link displayed on the terminal.
This project is licensed under the MIT License.
MIT © Prithvi MK