# Car Plane Detection using CNN – AI Project

This tutorial mainly focused on car plane detection based on Convolution Neural Network. We are using Python 3.7.3 and NumPy to build this program. But, you can use any version of Python to run this code.

The main aim of this tutorial is to improve our capacity to analyze the operating process and various CNN architecture based on detecting the car and the plane. Also to obtain knowledge on the basic parameter and hyperparameter that make up a complete program.

**The following are the steps to build a complete car plane detection model.**

- 1. The initial step is to collect the data for car and plane
- 2. Divide the dataset into train, test, and validate dataset (Download Dataset)
- 3. Train the CNN architecture to detect the car and the plane from our dataset which we have created.
- 4. The final step is to evaluate the result

**WORKING OF CNN**

We have introduced our CNN architecture for the classification and extraction of features from the dataset which we have created earlier.

CNN is also known as a multilayered neural network that is applied for image processing problems like the text in images, image recognition, self-driving cars, and powering vision in robots. CNN is a network of the neuron and has a three-layer which is named as a convolutional layer, padding layer, and third one ins fully connected layer. Our network is made up of 11 layers which do not involve the input layers because the input layer brings in a representation of the RGB color where each color is handled independently.

In our CNN architecture, the first two convolution layer is applied to an image in the layer by 16 of 3*3 filters. The third and fourth convolution layer is applied to an image in the layer by 32 of 3*3 filters.

The sub-layer of non-linear transformation uses the ReLu activation function because if the neuron activates the gradient is still strong which is equal to 1. A 2*2 filter is applied to the image by the max-pooling sublayer which results in the image size being reduced to half. In this point, each color channel is defined by 32*32 array which was extracts from 64 features of the convolutional network.

The eighth layer of our CNN architecture is known as the flatten layer to convert the multi-dimensional matrix of features into a one-dimensional array that can be fed into a neural network classifier that is fully connected and the one-dimensional array with size 4800 is used as the output of the flatten layer. The ReLu activation function with a fully connected artificial neural network (ANN) is used in the ninth layer which maps input values of 4800 to output values of 64. The dropout layer is the tenth layer. Thus, to overcome the issue of overfitting, fifty percent of the input values that come with layers is reduced to zero. The last eleventh layer is an ANN which is fully connected to maps 64 inputs values of 2 class labels with a sigmoid activation function.

Firstly, we use the data in the training set to train the convolution network to find suitable weights of filters in the three convolutional sub-layers and the weights which offer the two fully connected layers with a minimal error. Next, we use the data in the validation set to test the convolution network to get validation error and cross-entropy loss. Within the same process, we repeat the convolution network training until we reach up to 10 epochs.

#### **RESULT AND ANALYSIS **

We have plotted different graphs like iteration obtained graphs, graph based on loss and accuracy, and confusion matrix. Each graph shows the performance of our model.

While training the convolution network we have observed that loss is decreasing in each epoch. And also, shows that there is a minimum error while training our data.

Next, we have evaluated the graph based on model accuracy and model loss which shows the performance of our model on training and validation set, and each interaction we have observed better results.

At last, we have created a confusion matrix to evaluate the performance of our model. It provides us insight to calculate the mistake provided by a classifier.

In order to compare various techniques, the car plane detection project measures the following terms produced by the CNN model. Also, and uses them to compare and analyze the output of the different analyses of different quantitive measurements.

- 1. True Negative (TN)
- 2. False Negative (FN)
- 3. True Positive (TP)
- 4. False Positive

**TP: TP is the situation where the system classifies or recognizes the image of the plane as the plane. **

**TN: TN is the situation where the system classifies or recognizes the image of the car as the car.**

**FP: FP is the situation where the system classifies or recognizes the image of the car as the plane.**

**FN: FN is the situation where the system classifies or recognizes the image of the plane as the car.**

The following are the different evaluation matrices:

- 1.
**Accuracy:**Accuracy or the Detection Rate is the number that has been correctly classified which is also known as detection rate is the most efficient and widely used performance metric.

.Accuracy (ACC) = (TN +TP) / (TN + TP + FP +FN )= (44 +43) / (44+ 6+ 7+43) = 0.87

- 2.
**Precision:**Precision or Positive Predicted Value is used to classify how much model is right when it says it is right.

Precision = (TP) / (TP + FP )

precision of Class Plane = 44/(44+7) = 0.86

precision of Class Car = 43/(43+6) = 0.877

- 3.
**Recall:**Recall, True Positive Rate, Sensitivity, or Probability of detection measures the percentage of positive instances out of the total actual positive instances.

**Recall**: Recall, True Positive Rate, Sensitivity, or Probability of detection measures the percentage of positive instances out of the total actual positive instances.

Recall = (TP) / (TP + FN )

Recall of Class Plane = 44/(44+6) = 0.88

Recall of Class car = 43/(43+7) = 0.86

- 4.
**F1-Score:**F1-Score is the harmonic mean of precision and recall. The higher the value of the f1-score better will be the model.

F1-Score= (2 * Precision * Recall) / (Precision + Recall )

F1-Score of class Plane = 2 * 0.86 * 0.88 / (0.86 + 0.88) = 0.869

F1-Score of class Car= 2 * 0.877 * 0.86 / (0.877 + 0.86) = 0.868

- 5.
**Support:**It is the total number of the element present in the predicted class. Here the support for the class plane is 50 and the class car is 50.

- 6.
**Macro Average:**Normal Average in known as macro average .

Normal average for precision: (0.86 + 0.877) / 2 = 0.8685

Normal average for recall: (0.88 + 0.86) / 2 = 0.87

- 7.
**Weighted average:**The method of calculating a kind of arithmetic mean of a set of numbers in which some elements of the set have greater (weight) value than others

Greater weight value (Weighted average) for precision: {(0.86 * 51) + ( 0.877 *49 )} / 100 = 0.868

Greater weight value (Weighted average)for recall : {(0.88 * 50) + ( 0.86 *50 )} / 100 = 0.87

Pingback: Best Artificial Intelligence Project Ideas For FYP | GRASP CODING