0% found this document useful (0 votes)
16 views17 pages

AI Image Classification With Neural Network 221002564 222002074

Uploaded by

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

AI Image Classification With Neural Network 221002564 222002074

Uploaded by

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

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Semester: (Spring, Year: 2025), B.Sc. in CSE (Day)

Image Classification with Neural


Networks
Course Title: Artificial Intelligence Lab
Course Code: CSE 316
Section: 222 D7
Students Details
Name ID
Fuad Hossain 221002564
Tanjila Akter Shanta 222002074

Submission Date: 19-05-2025


Course Teacher’s Name: Mr. Mozdaher Abdul Quader

[For teachers use only: Don’t write anything inside this box]

Lab Project Status

Marks: Signature:

Comments: Date:
Contents

1 Introduction 3
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Problem Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Complex Engineering Problem . . . . . . . . . . . . . . . . . . 4
1.4 Design Goals/Objectives . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Design, Development, and Implementation of the Project 6


2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.1 Dataset Description . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Class Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.1 Project Workflow . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.2 Tools and Libraries Used . . . . . . . . . . . . . . . . . . . . . 8
2.3.3 Model Architecture and Code . . . . . . . . . . . . . . . . . . 8
2.3.4 User Interaction and Prediction . . . . . . . . . . . . . . . . . 9
2.4 Algorithm Description . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 Performance Evaluation 10
3.1 Simulation Environment and Procedure . . . . . . . . . . . . . . . . . 10
3.1.1 Training Configuration . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2 Testing Configuration . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Results Analysis and Testing . . . . . . . . . . . . . . . . . . . . . . . 11

1
3.2.1 Training and Validation Accuracy . . . . . . . . . . . . . . . . 11
3.2.2 Loss Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.3 Final Evaluation Metrics . . . . . . . . . . . . . . . . . . . . . 11
3.3 Overall Discussion of Results . . . . . . . . . . . . . . . . . . . . . . . 12

4 Conclusion 14
4.1 Summary and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 Scope for Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2
Chapter 1

Introduction

1.1 Overview
Image classification has become a cornerstone application in computer vision, powered
by the growth of deep learning. This project focuses on building a Convolutional Neural
Network (CNN) to classify images from the CIFAR-10 dataset, which contains 60,000
32x32 color images across 10 categories. In addition to implementing the model.We
designed a user friendly graphical interface using PyQt5, enabling real time training
and prediction capabilities through a GUI.

1.2 Motivation
The explosive growth in visual data ranging from autonomous driving systems to facial
recognition demands scalable and accurate classification systems. Our motivation stems
from the desire to understand and practically implement deep learning techniques us-
ing CNNs and to offer a simplified GUI-based interface so that nontechnical users can
also explore how these models function in practice. The integration of visualization
and control features bridges the gap between theoretical understanding and real-world
applications.

1.3 Problem Definition

1.3.1 Problem Statement


The challenge addressed in this project is how to accurately classify small-sized (32x32)
images from the CIFAR-10 dataset using a custom-built convolutional neural network.
The goal includes improving prediction accuracy.This allowing users to train and test
models easily through a GUI and understanding the inner workings of a classification
pipeline ranging from data pre processing to final prediction. These align directly with
our motivation of gaining hands on deep learning experience and making AI models
more approachable.

3
1.3.2 Complex Engineering Problem
The following Table 1.1 outlines how our project satisfies multiple attributes of complex
engineering problems.

Table 1.1: Summary of the attributes touched by the mentioned projects


Name of the P Attributes Explain how to address
P1: Depth of knowledge required Involves deep learning, CNN architectures,
backpropagation, data normalization, and loss
optimization.
P2: Range of conflicting require- Balancing model accuracy with GUI respon-
ments siveness and training speed on limited hard-
ware.
P3: Depth of analysis required Requires performance tuning, error analysis,
and layer-by-layer examination of model be-
havior.
P4: Familiarity of issues Must understand overfitting, underfitting, GPU
acceleration, and UI development.
P5: Extent of applicable codes Adheres to software engineering standards in
Python and uses TensorFlow/Keras libraries.
P6: Extent of stakeholder involve- GUI design considers ease-of-use for beginners
ment and conflicting requirements while retaining configuration options for ex-
perts.
P7: Interdependence The system includes interdependent compo-
nents: dataset loading, model training, image
preprocessing, and GUI handling.

1.4 Design Goals/Objectives


The project aims to:

• Build a CNN model that can classify CIFAR-10 images with high accuracy.

• Develop a PyQt5-based GUI allowing users to preview data, set training parame-
ters and make predictions.

• Provide an interactive educational tool for understanding neural networks.

• Ensure modularity and readability of code for educational and extension pur-
poses.

1.5 Application
This project has numerous real-world applications:

4
• Educational Tool: Helps students understand how deep learning pipelines work
through a visual interface.

• Prototype Builder: Offers a baseline for more complex classification tasks in


fields like medical imaging or autonomous systems.

• Research Foundation: Can be extended to transfer learning, model compression,


or other datasets like CIFAR-100 or ImageNet.

• User-Friendly Deployment: Enables demonstration of AI models to non-programmers


for client feedback or stakeholder presentations.

Figure 1.1: GUI Interface for Training and Prediction

Figure 1.2: Image Classification Using deep learning Convolutional Neural Network

5
Chapter 2

Design, Development, and


Implementation of the Project

2.1 Introduction
The goal of this project is to apply Convolutional Neural Networks (CNNs) to solve
the task of image classification using the CIFAR-10 dataset. Image classification plays
a vital role in many computer vision applications. The CIFAR-10 dataset offers a bal-
anced and well studied benchmark with 60,000 labeled images distributed across 10
object categories. This makes it suitable for training, evaluating and understanding the
performance of deep learning models

2.2 Project Overview


In this section we describe the core components of our CNN based image classification
system and explain how each part contributes to the overall functionality of the model.

2.2.1 Dataset Description


The CIFAR-10 dataset consists of 60,000 color images.Each of size 32x32 pixels and
labeled across 10 categories. Out of these, 50,000 images are used for training and the
remaining 10,000 are used for testing. The dataset is widely used in the deep learning
community for benchmarking performance.

2.2.2 Class Labels


Each image in the dataset belongs to one of the following 10 classes:

• Airplane

• Automobile

6
• Bird

• Cat

• Deer

• Dog

• Frog

• Horse

• Ship

• Truck

Figure 2.1: Sample images from the CIFAR-10 dataset, showing various categories

2.3 Implementation
The implementation phase includes four main tasks: dataset preparation, CNN archi-
tecture design, model training, and evaluation. We used Python along with key libraries
such as TensorFlow/Keras, NumPy, Matplotlib and OpenCV for development.

2.3.1 Project Workflow


The main steps involved in the implementation are as follows:

• Load and preprocess the CIFAR-10 dataset.

• Build a CNN model using the Keras Sequential API.

7
• Train the model and monitor its performance.
• Evaluate the model on unseen test data.
• Save the trained model for future use.
• Accept user input to test predictions using new images.

2.3.2 Tools and Libraries Used


The following tools and libraries were used in this project:

• Python 3.11 – Primary programming language


• Keras (TensorFlow backend) – Used for building and training the CNN
• NumPy – Used for handling arrays and image normalization
• Matplotlib – Used for visualization of images
• OpenCV (cv2) – Used for image reading, resizing, and preprocessing

2.3.3 Model Architecture and Code


We designed a CNN with three convolutional layers followed by max pooling, a dense
hidden layer and an output layer using softmax activation. The model was trained using
the Adam optimizer for 100 epochs.
( training_images , training_labels ) , ( testing_images ,
testing_labels ) = datasets . cifar10 . load_data ()
training_images , testing_images = training_images / 255.0 ,
testing_images / 255.0

model = models . Sequential ([


layers . Input ( shape =(32 , 32 , 3) ) ,
layers . Conv2D (32 , (3 ,3) , activation = ’ relu ’) ,
layers . MaxPooling2D (2 ,2) ,
layers . Conv2D (64 , (3 ,3) , activation = ’ relu ’) ,
layers . MaxPooling2D (2 ,2) ,
layers . Conv2D (64 , (3 ,3) , activation = ’ relu ’) ,
layers . Flatten () ,
layers . Dense (64 , activation = ’ relu ’) ,
layers . Dense (10 , activation = ’ softmax ’)
])

model . compile ( optimizer = ’ adam ’ ,


loss = ’ s p a r s e _ c a t e g o r i c a l _ c r o s s e n t r o p y ’ ,
metrics =[ ’ accuracy ’ ])

model . fit ( training_images , training_labels , epochs =100 ,


validation_data =( testing_images , testing_labels ) )

model . save ( ’ image_classifier . keras ’)

Listing 2.1: Model Definition and Training in Keras

8
2.3.4 User Interaction and Prediction
After training and saving the model, we created a feature that allows users to input an
image, which is then resized to 32x32 and passed to the trained model for prediction.
def g et _ u s e r _ in p u t _ i m a g e () :
image_path = input ( " Enter the image path : " )
img = cv . imread ( image_path )
if img is None :
print ( " Image not found . Please check the path . " )
return None
img = cv . cvtColor ( img , cv . COLOR_BGR2RGB )
img = cv . resize ( img , (32 , 32) )
return img

img = g e t _ u se r _ i n p u t _ i m a g e ()
if img is not None :
prediction = model . predict ( np . array ([ img ]) / 255.0)
predicted_class = np . argmax ( prediction )
print ( " Predicted class : " , class_names [ predicted_class ])

Listing 2.2: User Image Prediction

2.4 Algorithm Description


We used a standard feedforward Convolutional Neural Network (CNN) for classifica-
tion. The training pipeline is summarized in the algorithm below:
Algorithm 1: CNN-Based Image Classification on CIFAR-10
Input: CIFAR-10 dataset with labeled images
Output: Trained CNN model and classification accuracy
1 Normalize all input images to a range of [0, 1]
2 Construct CNN architecture using Conv2D, MaxPooling2D, Flatten, Dense
layers
3 Compile the model using Adam optimizer and cross-entropy loss
4 Train the model for 100 epochs using training data
5 Evaluate the model on test data to compute accuracy
6 Save the trained model to disk

2.5 Summary
This chapter discussed the practical design and development of our image classification
system. We successfully implemented and trained a Convolutional Neural Network us-
ing Python and Keras to classify CIFAR-10 images. The model achieved good accuracy
and was capable of predicting classes for new images provided by users.

9
Chapter 3

Performance Evaluation

3.1 Simulation Environment and Procedure


To evaluate the effectiveness of our Convolutional Neural Network (CNN) model, we
conducted experiments on a Windows 11 machine configured with 16GB RAM and an
Ryzen 5 5600u processor. All code was written in Python and the model was imple-
mented using TensorFlow and Keras APIs.

3.1.1 Training Configuration


The following parameters were used during training:

• Epochs: 35

• Batch Size: Default (as per Keras behavior)

• Loss Function: Sparse Categorical Crossentropy

• Optimizer: Adam

• Activation Functions: ReLU (hidden layers), Softmax (output layer)

3.1.2 Testing Configuration


For testing purposes 10,000 images from the CIFAR-10 test set were utilized. The
model was evaluated based on two primary performance metrics:

• Accuracy: Percentage of correctly predicted images.

• Loss: Categorical cross-entropy loss on the test data.

10
3.2 Results Analysis and Testing

3.2.1 Training and Validation Accuracy


The accuracy of the model during training and validation was plotted over 35 epochs to
visualize the progression of learning.

Figure 3.1: Trained the model

As seen in the figure, the model steadily improved its prediction capability, eventu-
ally stabilizing in both training and validation phases.

3.2.2 Loss Evaluation


Loss values also decreased significantly as training progressed, indicating that the model
was successfully minimizing the prediction error.

Figure 3.2: Training and validation loss over epochs

3.2.3 Final Evaluation Metrics


Upon completion of training, the model was evaluated on the held-out test dataset.

11
• Test Accuracy: 69.5%
• Test Loss: 0.89

Figure 3.3: Test Images

Figure 3.4: Get the user input image and Make prediction

These results reflect the model ability to generalize to unseen data which is a critical
benchmark in classification tasks.

3.3 Overall Discussion of Results


The CNN model achieved approximately 69.5% accuracy on the CIFAR-10 test set.
Given the low resolution and diverse nature of CIFAR-10 images, this is a promising
result for a relatively simple architecture.

12
Figure 3.5: Get the user input image and Make prediction

While the current performance is acceptable.There remains significant scope for


improvement. Possible enhancements include:

• Adding Dropout layers to reduce overfitting.

• Applying data augmentation techniques such as flipping, rotation and zooming.

• Tuning hyperparameters like learning rate, batch size and kernel size.

• Experimenting with deeper architectures such as ResNet or VGG variants.

13
Chapter 4

Conclusion

4.1 Summary and Discussion


This project focused on building an image classification system using Convolutional
Neural Networks (CNNs) on the CIFAR-10 dataset. Through the use of Python, Ten-
sorFlow and Keras.A CNN model was developed, trained over 100 epochs and tested
on unseen data. The final model achieved a test accuracy of 69.5%, demonstrating rea-
sonable classification capability given the simplicity of the model and the complexity
of the dataset.
The CNN architecture implemented in this project included multiple convolutional
layers, pooling layers and dense layers.It making it suitable for handling low resolution
RGB images.The model was able to learn and generalize well on the 10-class dataset.

4.2 Limitations
While the project achieved its core objectives, several limitations were observed during
development:

• No Dropout Layers: The absence of dropout layers may have led to overfitting,
especially in later epochs.

• No Data Augmentation: Training data was not augmented.Which limits the


model’s ability to generalize to slightly altered or noisy images.

• Shallow Architecture: The CNN used had a basic structure.Lacking the depth
and complexity found in state of the art models.

• Limited Optimization: No systematic hyperparameter tuning.

4.3 Scope for Future Work


There are several directions in which this project can be extended and improved:

14
• Model Enhancement: Employ deeper and more powerful architectures like ResNet,
VGG or DenseNet to improve accuracy.

• Data Augmentation: Incorporate techniques such as random cropping, flipping


and rotation to increase training data diversity.

• Regularization: Use dropout, batch normalization and early stopping to reduce


overfitting.

• Hyperparameter Tuning: Apply grid search or Bayesian optimization to fine


tune learning rate, filter sizes, activation functions etc.

• Deployment: Wrap the trained model in a user friendly web or desktop appli-
cation using frameworks like Flask, Streamlit or PyQt5 to allow real time image
classification.

• Transfer Learning: Experiment with pretrained models and fine-tune them for
the CIFAR-10 dataset to achieve better results with less training.

15
Bibliography

[1] A. Krizhevsky and G. Hinton, *Learning multiple layers of features from tiny
images*, Technical Report, University of Toronto, 2009.

[2] Y. LeCun, Y. Bengio, and G. Hinton, *Deep learning*, Nature, vol. 521, no. 7553,
pp. 436–444, 2015.

[3] I. Goodfellow, Y. Bengio, and A. Courville, *Deep Learning*, MIT Press, 2016.

[4] M. Abadi et al., *TensorFlow: Large-scale machine learning on heterogeneous


systems*, 2015. Software available from https://www.tensorflow.org.

[5] A. Krizhevsky, *The CIFAR-10 dataset*, https://www.cs.toronto.edu/


~kriz/cifar.html.

16

You might also like