The following repo is an image classfier for cars built for the grab AI for SEA Challenge (Computer Vision Challenge)
- Ubuntu 18.04
- Anaconda (Python 3.6.8)
- Keras (Tensorflow Backend)
- Nvidia-GTX 1080
git clone https://github.com/edwin-19/Car-Recognition.git
pip install -r requirements.txt
NOTE: Change the config file for model path
To run the script make sure to download the architecture and weights from the following Google Drive and add it to models folder e.g:
- models/vgg16
- models/resnet
python predict.py --image dataset/cars_test/00001.jpg --show_image
python batch_predict.py --image_folder dataset/test/
NOTES: Results are classfied_name followd by - then the perecentage:
Suzuki Aerio Sedan 2007 - 58.42927694320679.jpg
Using FLASK to serve as a flask rest api:
python app.py
Use POSTMAN or any other client to parse the following link(http://localhost:8080/recognize_car) and set it to post as such:
The dataset used to train the classfier is the Standford Car Dataset and put inside the raw_data folder as such:
Download the following three:
- Training Image
- Testing Image
- Car Devkit
then unzip all tar files and add to the following directory inside src:
Or you can just run the following script to download and unzip:
python download_cardataset.py
Generate labels from mat file from car devkit and convert them into a CSV format:
python generate_annotation.py
Split the dataset by 8:2 ratio as the test dataset has no labels so we will split from training set and move the training images into files labelled
python split_train_test.py
NOTE: For this repo VGG16 is the most recommended architecture and Resnet50 was included for the sake of trying out certain architectures but accuracy is lesser than VGG16
For this repo i have used tranfer learning from pretrained weights using the following architectures:
- VGG16
- It trains twice, the second time to fine tune the weights
-
python train_vgg16.py
-
- Resnet50
- The pretrained weights were downloaded from another repo here (script will automatically download if there isn't any)
-
python train_resnet50.py
-
Run evaluation script to print report and confusion matrix
python evaluate.py
- Model architecture used is vgg16
- Tested on training set with an accuracy of 70+%
The following code was mostly insipired based on a similar challenge by KAGGLE:
https://www.kaggle.com/jutrera/training-a-densenet-for-the-stanford-car-dataset
I Borrowed the evaluation method from the following notebook - I DO NOT take credit for it