Object Classification(Electric Car and Electric Bus Classification)

Object Classification(Electric Car and Electric Bus Classification)
Photo by Ahmed Maghrabi on Dribbble

Classification is the categorization of the object based on defined classes..

Introduction

Object Detection is one of the most famous and extensively researched topics in the field of Machine Vision. To understand Object Detection in simplistic terms, it deals with identifying and localizing some of the classes such as person, car, bus, spoon, etc. from the image.

In this article, let’s have a proper understanding of these trends which are followed in Deep and other Traditional Learning approaches. We will also be looking at the upsides and downside of both the approaches in a modularized fashion — Object Detection.

Classification/Regression

The final step of our pipeline is to classify the existing crops using the obtained feature descriptor values and assign a crop to a given class. Simultaneously, drawing a bounding box around an object in a given image. Most of the well-known classification techniques used are Support Vector Machines, AdaBoost, Random Forest, etc.

These models need far more information about a class and so, tedious tweaking is needed to get good results. For example, SVM generally does not support class probability discrimination. So, it becomes very tedious in multi-class classification.

These methods also fail in generalizing the data i.e. SVM generally performs very bad on the data containing noise and have overlapping data points.

But after the advent of the CNNs and Deep Neural Network architecture, it has become more convenient and reliable to fill the gaps which are present in the traditional object detection algorithms.

Importing the necessary libraries

We will use some commonly used libraries like Matplotlib. We will use Matplotlib to access the images and display it in the notebook.

Other imports include Tensorflow and Keras to create the convolutional neural network and perform preprocessing of the data to perform training on it.

Preparing the data

The training data is present inside Two folders — Electric Bus and Electric Car. We will use the ImageDataGenerator offered by Keras to prepare the data and get appropriate labels pertaining to the folder structure.

Image Preprocessing

Creating the Model

As mentioned, we will create a Convolutional Neural Network to predict the correct classes of cells from the images. We have used 3 Conv2D layers with MaxPool2D layers after each for the feature extraction from the images.

The activation function used is ReLU. The output layer has only three neurons corresponding to the two classes of Electric Bus and Electric Car, with Sigmoid activation function.

Creating the Model

 

The model summary for the above created model is as follow:

Model Summary

Compiling and Training the Model

We will compile the model with Adam as the optimizer and Binary Crossentropy as the loss function. We will train the model for 20 epochs. We will store the accuracy, loss, val_accuracy and val_loss at each epoch in the history for plotting meaningful data later.

Accuracy & Loss

We will now plot the model performance at each epoch during the training phase.

Training accuracy and Validation accuracy
Training accuracy and Validation accuracy

Training loss and Validation loss
Training loss and Validation loss

Model Evaluation:

Model Evaluation

 

Notebook: Here

Credit: Mohd Shariq Malik

Also Read: Detecting Car Damage Using Deep Learning

Related Posts