0% found this document useful (0 votes)
35 views8 pages

Convolutional Neural Network Project On Image Classification

This project aims to use a pre-trained convolutional neural network to classify images from the Caltech 101 dataset into categories. The project involves loading a pre-trained ResNet-50 model, preprocessing the images, fine-tuning the model on the dataset, and evaluating the accuracy of the model on test images.

Uploaded by

Reality Aielumoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views8 pages

Convolutional Neural Network Project On Image Classification

This project aims to use a pre-trained convolutional neural network to classify images from the Caltech 101 dataset into categories. The project involves loading a pre-trained ResNet-50 model, preprocessing the images, fine-tuning the model on the dataset, and evaluating the accuracy of the model on test images.

Uploaded by

Reality Aielumoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CONVOLUTIONAL NEURAL NETWORK PROJECT ON IMAGE CLASSIFICATION

Aim: To use a pre-trained convolutional neural network to identify different images according to their
categories.

Software Used: MATLAB

DataSet: Caltech 101

INTRODUCTION

In this project, a pre-trained Convolutional Neural Network (CNN) will be utilized to classify images
from the Caltech 101 dataset. The Caltech 101 dataset is composed of images belonging to 101
categories, such as "airplanes," "elephants," and "sunflowers." The objective is to fine-tune the pre-
trained CNN on the Caltech 101 dataset to obtain high accuracy in categorizing images according to
their respective classes. To achieve this goal, the weights of the CNN will be adjusted to adapt to the
specific task rather than starting the training from scratch. MATLAB, a widely-used software for
implementing and training deep learning models, will be employed to load the pre-trained CNN, pre-
process the images in the dataset, fine-tune the CNN, and assess the accuracy of the model on a test
set of images.

PROCEDURES:

Step 1: A new file ‘Classification’ was created and saved into a folder using the fullfile function to
obtain the full file path of the folder.

Step 2: The Caltech 101 dataset was downloaded and extracted into a folder named 'Caltech101'. The
dataset contains subfolders for each category, with each subfolder containing images belonging to
that category.
Step 3: To limit the image classification to three categories - "ferry," "airplanes," and "laptop," the
images belonging to these categories were selected from the original 'Caltech101' dataset and stored
in a variable called "categories."

Step 4: An Image Datastore (IMDS) was created to handle the images. The advantage of using an
IMDS is that it operates on the image file locations and not on the images in memory until they are
read. This makes it more efficient and easier to use.

Step 5: The images of the three categories were stored in the IMDS using the full file and rootFolder
functions. The first argument in full file represented the location of the images, and the second
argument represented the name and value for creating the IMDS. The labelsource was set to
"foldernames," which named the images according to their corresponding folder names.

Finally, the number of images in each of the three categories was counted using the countEachLabel
function.
Step 6: As the number of images in each category is not the same, it may lead to problems in image
classification. To address this issue, the minimum number of images among the three categories was
counted using the min function.

Step 7: In order to make the number of images in each category the same, we used the
splitEachLabel function. This function allowed us to randomly select 67 images from each category,
making a total of 201 images.

Step 8: Variables for each of the three categories - "airplanes," "laptop," and "ferry" - were defined
using the subset function. This function subsets the IMDS and returns a new datastore containing
only the images with the specified label.

After defining the variables, each category was plotted using the montage function. This function
displays multiple image frames as a montage.
Step 9: We used a pre-trained ResNet-50 model and displayed its architecture using the resnet18
function.

Step 10: We used a function in Matlab to resize the ResNet-50 model in order to gain a better
understanding of its architecture.
Step 11: To determine what kind of images the ResNet-50 model accepts, the first and last input
layers of the model were inspected. The first input layer was found to be a 7x7 convolutional layer
that takes in 224x224x3 images, where 224x224 is the image size and 3 is the number of color
channels (RGB). The last layer of the model is a fully connected layer with 1000 output nodes,
representing the 1000 ImageNet categories that the model was originally trained on.

Therefore, it can be concluded that the ResNet-50 model accepts 224x224 RGB images as input.

Therefore, it can be concluded that the ResNet-50 model accepts 224x224 RGB images as input.

Alternatively, the "analyzeNetwork" function can be used to determine the number of classes in the
output layer of the ResNet-50 model.
Step 12: The Caltech 101 image dataset was divided into training and test sets using the
"splitEachLabel" function in Matlab. This function was applied to the image datastore "imds", with
30% of the images used for training and 70% for validation.

To determine the required input size for the ResNet-50 model, we inspected the first layer using the
"analyzeNetwork" function in Matlab. We found that the first layer is a 7x7 convolutional layer that
takes in 224x224x3 images, where 224x224 is the image size and 3 is the number of color channels
(RGB). Therefore, we can conclude that the ResNet-50 model requires 224x224 RGB images as input.

The size of the images is changed to match the required input size and any grayscale images are
converted to RGB using an augmented Image Datastore.

Step 13: The size was changed to correspond to the required input size and grayscale images were
converted to RGB using augmented imageDatastore for both training and test datasets.

The features of the images were visualized to understand why the features extracted from CNN work
so well for image recognition. This was done by converting the weight from a matrix to an image
using Matlab's mat2gray function and then displaying it.
Step 14: Visualize the performance of the fine-tuned model using various metrics such as precision,
recall, and F1 score.

Step 15: The values in the confusion matrix are converted into percentages to get a better
understanding of the classification performance. The mean of the percentages is then taken as the
accuracy of the model.

Step 16: The values in the confusion matrix are converted into percentages to get a better
understanding of the classification performance. The mean of the percentages is then taken as the
accuracy of the model.

Step 17: To test the ResNet-50 model, we loaded a picture and tested it using the trained model. The
model was able to identify the contents of the picture with high accuracy
RESULTS: The project was successful in developing a model that could classify images into three
classes - airplanes, laptops, and ferries. The model was able to accurately differentiate between the
classes and assign the correct label to each image. This means that given a new image of an airplane,
laptop or ferry, the model would be able to predict the correct class with a high degree of accuracy.

CONCLUSION: In conclusion, the deep learning model was able to achieve a high level of accuracy in
classifying images of airplanes, laptops, and ferries. This suggests that the model could be applied to
other similar classification tasks with comparable levels of success. However, there may be limitations
to the model's accuracy when faced with more complex or diverse image datasets. Further research
and optimization could be pursued to improve the model's performance. Overall, this project
highlights the potential of deep learning models for image classification tasks and underscores the
importance of continued exploration in this field.

You might also like