Object Classifier Using CNN

Photo by Cabify Design on Dribbble

According to Wikipedia:

Contextual image classification, a topic of pattern recognition in computer vision, is an approach of classification based on contextual information in images. “Contextual” means this approach is focusing on the relationship of the nearby pixels, which is also called neighborhood. The goal of this approach is to classify the images by using the contextual information.

Object Classification is a process of classifying the images of objects according to their class labels with the help of computer vision and deep learning.

Table of Contents:

→Dataset

→Data Preparation

→Image Preprocessing

→Model Training

→Model Evaluation

→Graph Plot

→Model Prediction


Dataset:

The dataset is available on Kaggle which was given by Prashant Chaturvedi

https://www.kaggle.com/positivepc/object-detection

The data is divided into two types: test data and train data. The training set contains 1486 images, whereas the testing set contains 392. The images in the collection were largely clear and well-formatted.

There are in all 2 labels which we need to predict.

  1. Electric Bus
  2. Electric Car

Data Preparation:

The dataset already included the training and test sets. The validation set, however, was missing. As a result, we needed to divide the training data set into an 80:20 ratio, i.e. (1486 for training and 297 for validation).

Image Preprocessing:

By definition, Image Processing is a method to perform some operations on an image ,in order to get an enhanced image or to extract some useful information from it. It is a type of signal processing in which input is an image and output may be image or characteristics/features associated with that image.

Rescaling :

Because the image size has a maximum pixel of 255, i.e. it has a range of [0,255], the model will struggle to process such a large image, thus we must rescale it before feeding it to the model.

https://gist.github.com/tanmay1070/5fdb3bcd8f9bdbcb905c8de88fc72ea8

Data Preprocessing

https://gist.github.com/tanmay1070/da9b9c1a9cb1238613120857f7deee2c

Model Training :

We are using CNN for training the model,

epoch_size=10

optimizer=adam

https://gist.github.com/tanmay1070/35861a3cbb65fdb3190197043a2fefb2

Model Evaluation:

The model performed very well on the validation as well as on training set .The model was able to yield an overall accuracy of 98.4% and an accuracy of approximately 82% on validation set.

https://gist.github.com/tanmay1070/e5b8f501e46d6fac413f06cda008df9f

Graph Plot :

Train V/S Val (Loss)
Train V/S Val (Accuracy)

Model Prediction :

https://gist.github.com/tanmay1070/ffab269998fee5e73918a5a76c25a4f1

Link :

Click the below link to access the Notebook .

https://cainvas.ai-tech.systems/use-cases/vehicle-classification-app/

Credit: Tanmay