An image classification project to classify among anime, animation and cgi characters from data collection, machine learning to deployment. Defining the labels.
anime: anime characters from an original anime
animation: animation characters from an animation movie or series
cgi: CGI characters from a real movie [no animation]
Data Gathering: Downloaded from Google Images by Google Image Search using keywords
DataLoader: Used fastai DataBlock API to set up the DataLoader.
Data Augmentation: fastai provides default data augmentation which operates in GPU.
Data Cleaning: This part took the highest time. Since I collected data from Google Images, there were many noises. Also, there were images that contained anime and animation or anime and CGI, which is not my goal right now for this project. I cleaned and updated data using fastai ImageClassifierCleaner.
Training: Fine-tuned a resnet50 model for 5 epochs and got upto 80% accuracy.
Confusion Matrix: Looking into the confusion matrix I understood that the model can identify the anime and animation clearly but the 'CGI' images were confusing between anime and animation which actually is very logical if we think about it.
Setting up for Inference: After more fixing, I set up the model for inference. The results on random images were satisfactory.
Built a basic web frontend and backend with Flask, HTML, CSS and others, integrated the trained model and prepared everything for deployment.
- Clone the Git Repo
$ git clone https://github.com/msi1427/https://github.com/msi1427/Anime-vs-Animation-vs-CGI.git
$ cd Anime-vs-Animation-vs-CGI
- Initialize and activate a virtualenv
$ virtualenv --no-site-packages env
$ source env/bin/activate
# For Windows
$ source .\env\Scripts\activate.bat
- Install the dependencies
$ pip install -r requirements.txt
- Run the development server
$ python app.py
- Navigate to http://localhost:5000
- Given an image, it can classify among Anime, Animation and CGI characters
YouTube Link: https://youtu.be/aK4_xdcn2Yg
After building from sources, navigate to http://localhost:5000
There we land here
When we add an image and mark it to classify. We get to this page.
Clicking on Classify Image will take back to the landing page.
Deployed the Web app to Heroku.
Important thing I noticed here is that numpy, pandas and scipy library versions doesn't match with the Heroku version so I changed those to previous versions and it worked. However, I could not deploy my model to Heroku because the whole thing was nearly 1 GB and Heroku does not approve more than 500MB for free.
fastai course: https://course.fast.ai/
Flask Tutorial: https://www.youtube.com/watch?v=Z1RJmh_OqeA