You are on page 1of 12

Image Classification Using Deep Learning in

Matlab

Group Members:
Ashutosh Lembhe(18BEE1025),
Mayank Raje(18BEE1082), Siva Kumar(18BEE1019),
Adarsh Menon(18BEE1041)

Neural Networks and Fuzzy Logic


EEE1007
Project Report
INDEX

1. Objective.

2. Code and Block Diagram.


a. Code Explanation.
b. Block Diagram Explanation.

3. Simulation and Training Results.


a. Simulation Explanation.
b. Prediction Results.

4. Applications.

5.Summary.
Objective:
The aim of the project is to:
1. Image classification based on input.
2. To implement a Neural network in Matlab and train it for
maximum accuracy.
3. To compare the Neural network accuracy with a pre-
trained neural network.

Code/Block Diagram:
Part 1 (Building and training a CNN)
a. Code Explanation.
i. We build an ImageDatastore consisting of 12 folders (corresponding to the 12
categories of different flower dataset) with images of each flower. We have
taken the flowers dataset because it has a good amount of photos on each
flower to train the neural network.
ii. Case 1: Splitting dataset into training (70%) and testing (30%).
iii. We create an augmentedImageDatastore to handle image resizing, specifying
the training images and the size of output images, which must be compatible
with the size expected by the input layer of the neural network..
Final Matlab Code.
b. Block Diagram.

i. Above is the representation of how the neural network is connected and


will help us understand how our neural network is made.
ii. Right now our network is a 14 layer neural network.
iii. First in the layer is an image resizing layer which converts images into
224,224,3 dimension.
iv. Then convolution 2d layer and batch normalization layer.
v. Then is the Relu activation function which is used for image classification.
vi. Then we have the Max pooling layer which performs down-sampling by
dividing the input into rectangular pooling regions, and computing the
maximum of each region.
vii. Then the same order is repeated from 1 to 4.

Part-2 (Using a Pretrained “Alexnet” ).


c. Code Explanation.
i. Repeating the following process of creating a data file.
ii. Making training datasets and test data sets.
iii. And Making confusion matrix.
About Alexnet: AlexNet is a convolutional neural network that is 8 layers deep. The
pre-trained network can classify images into 1000 object categories, such as
keyboard, mouse, pencil, and many animals. As a result, the network has learned
rich feature representations for a wide range of images. The network has an image
input size of 227-by-227.
This is the full method we have used to build our Alexnet modified
neural network.

Output Images/Training Results:


Part-1 Result:
The Training output was not what we expected the accuracy of the neural network model
was around 47.40%.
The accuracy could be increased if we increase the Training data to 80%.

Training of neural network after 80% training data set and testing only 20%.
See the 12th line of the Matlab code the training dataset has been changed to 80%

After training the accuracy has increased to 60% which is a significant change.

Importing Images to verify if the Trained Network works properly or not.


Here we got the Wrong answer as we know the trained network accuracy is low around
47-60% it is bound to happen if we increase the neural layer we can increase accuracy and
get the correct results. Here the correct answer should be BLUEBELLS when it predicted
but gave IRIS as the answer.
Now we will check if we could achieve more accuracy with a pre-trained model “Alexnet”

Part-2 Result:
Epoch and accuracy for different batches with 0.001 learning rate.

We have got an accuracy of 85% for the Alexnet model with a 60% training dataset.

Confusion Matrix.
We then train the network and evaluate the classification accuracy on the
validation set. The resulting confusion matrix gives us additional insights on
which categories are misclassified more frequently by the model. So out of 80
total images for each class, 60%=48 images for training, 40%=32 images for
testing and verifying.
Importing the same flower BLUEBELLS to check the accuracy on this pre-trained network.

Checking if the Label and classification is correct or not.


We can see that the pre-trained network worked correctly and it labeled the flowers
correctly as it has the accuracy of 80+%.
Using any pre-trained network will give you an accuracy of 80% or more.
Applications:
1. The above Neural network which we made has lots of applications from image
classification to using the network in an autonomous vehicle for object detection.
2. Manufacturing—image recognition is employed in different stages of the
manufacturing cycle. It is used to reduce defects within the manufacturing process,
for example, by storing images of components with related metadata and
automatically identifying defects.
3. Automotive industry—autonomous vehicles are in testing phases in the United
States and are used for public transport in many European cities. To facilitate
autonomous driving, image recognition is taught to identify objects on the road,
including moving objects, vehicles, people, and pathways, as well as recognize traffic
lights and road signs.
4. Gaming industry—image recognition can be used to transpose a digital layer on top
of images from the real world. Augmented reality adds details to the existing
environment. Pokemon Go is a popular game that relies on image recognition
technology.

Summary:
1. We saw that when we built our own neural network the accuracy we got is less.
2. But we can increase the accuracy by increasing the training dataset.
3. We also trained the pre-trained network by modifying its layers according to us.
4. The Custom-made Neural Network obtained an accuracy of 47-60% depending on the
training percent.
5. The Alexnet obtained an accuracy of 85%. Here the difference between Alexnet using
more layers than our network requires less training data then our neural network
which is 60%-Alexnet and 70-80%-Custom Neural network.
6. Both neural networks were compared trained, predicted and results were obtained.
7. The custom neural network gave us an insight into how neural networks work for
image classification.

You might also like