Skip to content

AnggaPradiktas/GrabAIChallenge

Repository files navigation

GrabAIChallenge

Computer Vision on Predicting Car Feature How might we automate the process of recognizing the details of the vehicles from images, including make and model?

Problem Statement

Given a dataset of distinct car images, can you automatically recognize the car model and make?

Dataset

We use the Cars Dataset, which contains 16,185 images of 196 classes of cars. The Cars dataset contains 16,185 images of 196 classes of cars. The data is split into 8,144 training images and 8,041 testing images, where each class has been split roughly in a 50-50 split. Classes are typically at the level of Make, Model, Year, e.g. 2012 Tesla Model S or 2012 BMW M3 coupe.

Training images can be downloaded here.

Testing images can be downloaded here.

A devkit, including class labels for training images and bounding boxes for all images, can be downloaded here.

ImageNet Pretrained Model for fine-tuning

Download fine-tuning imagenet pre-trained model for theano and tensorflow backend here.

Code

Preprocessing

First download all the data needed from the link above and then split and assign them into train, test, and valid. You can see the preprocessing code in img_annot_preprocessing.ipynb

Batch Normalization

Then create a custom layer for BatchNormalization. I am using Resnet-152 as a fine-tuning method to do car recognition. Learns a set of weights and biases used for scaling the input data. You can access the layer code here scale_layer.py

Resnet 152 Model

Then I created Resnet-152 pre-trained model. Model Schema and layer naming follow that of the original Caffe implementation https://github.com/KaimingHe/deep-residual-networks. I put the code in model_resnet152.py (.py) instead of Jupyter so that I can import it easily for my next code.

Train the Data

And the I trained the data using the model to get the best accuracy. After some loopings I decided to use model.46-0.99.hdf5 model on epoch 46. You can find the code here train.ipynb.

val_acc val_loss

Testing

And after some training, finally I tested the data using the trained model for random 20 data in test dataset. Before that I also created a util.py to make it easier for me importing the model inside any code. Here's the code demo_test.ipynb and save the output in the results.json. I also visualize the output below.

Environment

I run almost my entire code using Google Colab, here's the link to my drive and Colab https://drive.google.com/open?id=1rMQeVOWd7l_YxrXTy-eE6onfwcVU6v9F

demo_test.ipynb results

1 2 3 4
image image image image
Ford Mustang Convertible 2007', 'prob': '0.9883' 'Audi TT RS Coupe 2012', 'prob': '0.8998' 'Audi S5 Coupe 2012', 'prob': '0.9446' 'Aston Martin V8 Vantage Convertible 2012', 'prob': '0.9771'
image image image image
'Audi RS 4 Convertible 2008', 'prob': '0.9997' 'BMW Z4 Convertible 2012', 'prob': '0.9999' 'Fisker Karma Sedan 2012', 'prob': '1.0' 'Dodge Challenger SRT8 2011', 'prob': '1.0'
image image image image
'Lamborghini Diablo Coupe 2001', 'prob': '0.9612' 'Nissan Leaf Hatchback 2012', 'prob': '1.0' 'Land Rover Range Rover SUV 2012', 'prob': '0.9999' 'Jeep Liberty SUV 2012', 'prob': '0.9961'
image image image image
'Buick Regal GS 2012', 'prob': '0.9996' 'GMC Savana Van 2012', 'prob': '0.4698' 'Bugatti Veyron 16.4 Coupe 2009', 'prob': '0.9959' 'BMW 3 Series Sedan 2012', 'prob': '0.9999'
image image image image
'Daewoo Nubira Wagon 2002', 'prob': '0.9821' 'Ford F-150 Regular Cab 2007', 'prob': '0.9995' 'smart fortwo Convertible 2012', 'prob': '0.9995' 'Chevrolet Impala Sedan 2007', 'prob': '0.9991'

About

Computer Vision on Predicting Car Name, Year

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published