0% found this document useful (0 votes)
3 views51 pages

CNN-Based Skin Cancer Detection System

The project report titled 'Skin Cancer Detection Using CNN' by Jaseel M V focuses on developing a system utilizing Convolutional Neural Networks (CNNs) for the early detection of skin cancer, which is crucial for improving patient outcomes. The system employs a comprehensive dataset of dermatoscopic images, enhancing image quality through preprocessing, and aims to assist dermatologists in accurate diagnosis via a user-friendly interface. This project contributes to the integration of deep learning technology in healthcare, promoting proactive practices in skin cancer management.

Uploaded by

edm20d014
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)
3 views51 pages

CNN-Based Skin Cancer Detection System

The project report titled 'Skin Cancer Detection Using CNN' by Jaseel M V focuses on developing a system utilizing Convolutional Neural Networks (CNNs) for the early detection of skin cancer, which is crucial for improving patient outcomes. The system employs a comprehensive dataset of dermatoscopic images, enhancing image quality through preprocessing, and aims to assist dermatologists in accurate diagnosis via a user-friendly interface. This project contributes to the integration of deep learning technology in healthcare, promoting proactive practices in skin cancer management.

Uploaded by

edm20d014
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

Skin Cancer Detection Using CNN

A Project Report

submitted by

JASEEL M V (EVD18I030)

in partial fulfilment of requirements


for the award of the degree of

BACHELOR OF TECHNOLOGY AND MASTER OF TECHNOLOGY

Department of Electronics and Communication Engineering


INDIAN INSTITUTE OF INFORMATION TECHNOLOGY,
DESIGN AND MANUFACTURING KANCHEEPURAM
MAY 2024
DECLARATION OF ORIGINALITY

I, Jaseel M V, with Roll No: EVD18I030 hereby declare that the material presented
in the Project Report titled Skin Cancer Detection Using CNN represents original
work carried out by me in the Department of Electronics and Communication Engi-
neering at the Indian Institute of Information Technology, Design and Manufacturing,
Kancheepuram.
With my signature, I certify that:

• I have not manipulated any of the data or results.

• I have not committed any plagiarism of intellectual property. I have clearly indi-
cated and referenced the contributions of others.

• I have explicitly acknowledged all collaborative research and discussions.

• I have understood that any false claim will result in severe disciplinary action.

• I have understood that the work may be screened for any form of academic mis-
conduct.

Jaseel M V

Place: Chennai
Date: 13.05.2025
CERTIFICATE

This is to certify that the report titled Skin Cancer Detection Using CNN, submit-
ted by Jaseel M V (EVD18I030), to the Indian Institute of Information Technology,
Design and Manufacturing Kancheepuram, for the award of the dual degree of BACH-
ELOR OF TECHNOLOGY AND MASTER OF TECHNOLOGY is a bonafide
record of the work done by him/her under my supervision. The contents of this report,
in full or in parts, have not been submitted to any other Institute or University for the
award of any degree or diploma.

Dr. Binsu Kailath


Project Guide
Professor
Department of Electronics and Communication Engineering
IIITDM Kancheepuram, 600 127

Place: Chennai
Date: 13.05.2025
ACKNOWLEDGEMENTS

I want to express my gratitude to the Electronics and Communication Engineering De-


partment of Indian Institute of Information Technology Design and Manufacturing,
Kancheepuram for offering me the chance to work on this research as my final year
project,with the guidance of Prof. Binsu J Kailath.

I am sincerely grateful to Prof. Binsu J Kailath for providing me with this excep-
tional opportunity to undertake my design project under her esteemed mentorship. Her
continuous encouragement and valuable feedback have improved my problem solving
and understanding in different areas. Even though there was engaged in a lot of work,
she always finds time to answer all of my doubts and queries, and I appreciate her for
all the support of her during this project and other points of my degree.

I would like to add the support that my family and friends have given me throughout
this project and their role played an integral part of my life journey. Whose presence
and love made me an improved student and a human being throughout this time period.

i
ABSTRACT

Skin cancer is one of the most prevalent types of cancer, and its early detection is crucial
for successful treatment and improved patient outcomes. In recent years, deep learning
techniques, particularly Convolutional Neural Networks (CNNs), have demonstrated
exceptional performance in various computer vision tasks, including medical image
analysis. This project aims to develop a skin cancer detection system using CNNs to
assist dermatologists in accurate and efficient diagnosis.

The proposed system leverages a comprehensive dataset of dermatoscopic images


obtained from diverse sources, encompassing various skin lesion types and disease
stages. The dataset is preprocessed to enhance image quality and eliminate noise, en-
suring optimal performance during the training phase. We begin with an overview of
three types of dermatological images, followed by a list of publicly available datasets
relating to skin cancers. After that, we review the successful applications of typical
convolutional neural networks for skin cancer classification.

The trained CNN model is capable of automatically extracting relevant features


from input dermatoscopic images and classifying them into different categories, such
as cancer cells(malignant) or non-cancer cell(benign). Additionally, a user-friendly in-
terface is developed to facilitate easy interaction between user and the system, allowing
for efficient analysis and integration into clinical workflows and better understanding.
The user doesn’t require knowledge in coding to run this system.

The proposed skin cancer detection system using CNNs offers the potential to assist
dermatologists in accurate and timely diagnosis, leading to improved patient outcomes.
By leveraging the power of deep learning and advancements in medical image anal-
ysis, this project contributes to the ongoing efforts in leveraging technology for the
early detection and management of skin cancer, thereby promoting proactive healthcare
practices.

ii
TABLE OF CONTENTS

ACKNOWLEDGEMENTS i

ABSTRACT ii

LIST OF TABLES v

LIST OF FIGURES vi

ABBREVIATIONS vii

NOTATION viii

1 INTRODUCTION 1
1.1 LITERATURE REVIEW . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 MOTIVATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 METHODOLOGY 5
2.1 PROBLEM STATEMENT . . . . . . . . . . . . . . . . . . . . . . 5
2.2 EXISTING SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 PROPOSED SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . 6

3 WORK DONE 7
3.1 DERMATOLOGICAL IMAGES AND DATASETS . . . . . . . . 7
3.1.1 Dermatological Images . . . . . . . . . . . . . . . . . . . 7
3.1.2 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 Benign vs Malignant . . . . . . . . . . . . . . . . . . . . . 8
3.1.4 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.5 Digital Image Processing . . . . . . . . . . . . . . . . . . . 9
3.1.6 Study Selection . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 CONVOLUTIONAL NEURAL NETWORK . . . . . . . . . . . . 10

iii
3.2.1 CNN Architecture . . . . . . . . . . . . . . . . . . . . . . 10
3.2.2 Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.3 Operations of CNN . . . . . . . . . . . . . . . . . . . . . 15
3.2.4 CNN vs Neural Networks . . . . . . . . . . . . . . . . . . 19
3.2.5 Benefits of using CNNs for deep learning . . . . . . . . . . 19
3.2.6 Applications of Convolutional Neural Network . . . . . . . 20
3.3 SYSTEM REQUIREMENTS and LIBRARIES . . . . . . . . . . . 23
3.3.1 Hardware requirements (Recommended) . . . . . . . . . . 23
3.3.2 Software requirements . . . . . . . . . . . . . . . . . . . . 23
3.3.3 Libraries Used . . . . . . . . . . . . . . . . . . . . . . . . 25

4 RESULT 31
4.1 IMPLEMENTATION AND TESTING . . . . . . . . . . . . . . . . 31
4.1.1 Proposed Architecture . . . . . . . . . . . . . . . . . . . . 31
4.1.2 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.1.3 Working . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.1.4 Results and Findings . . . . . . . . . . . . . . . . . . . . . 34

5 CONCLUSION AND FUTURE SCOPE 38


5.1 CONCLUSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2 Future Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
LIST OF TABLES

1.1 A sample table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

v
LIST OF FIGURES

3.1 CNN Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


3.2 Convolutional Layer of CNN . . . . . . . . . . . . . . . . . . . . . 12
3.3 Pooling Layer of CNN . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Fully Connected Layer of CNN . . . . . . . . . . . . . . . . . . . 14
3.5 Dropout Layer of CNN . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6 The difference between CNN and RNN . . . . . . . . . . . . . . . 20

4.1 The difference between CNN and RNN . . . . . . . . . . . . . . . 31


4.2 Hyperparameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3 Training loss and accuracy graph . . . . . . . . . . . . . . . . . . 37
4.4 Confusion Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

vi
ABBREVIATIONS

CNN Convolutional Neural Networks


VS Visual Studio
RNN Recurrent Neural Networks
GUI Graphical User Interface
ReLU Rectified Linear Unit

vii
NOTATION

λ wavelength

viii
CHAPTER 1

INTRODUCTION

Skin cancer is a widespread and potentially life-threatening disease with increasing


incidence rates worldwide. Early detection plays a vital role in improving treatment
outcomes and saving lives. Dermatologists traditionally rely on visual inspection and
biopsy analysis to diagnose skin cancer, which can be time-consuming and subjective.
To address these challenges, advancements in deep learning, particularly Convolutional
Neural Networks (CNNs), have shown promising results in various computer vision
tasks, including medical image analysis.

This project aims to develop a skin cancer detection system using CNNs, which can
assist dermatologists in accurate and efficient diagnosis. By leveraging the power of
deep learning, the proposed system aims to automate the process of skin lesion classi-
fication, improving the speed and accuracy of detection. This can potentially enhance
the overall effectiveness of dermatologists’ diagnostic capabilities, leading to timely
interventions and improved patient outcomes.

CNNs have revolutionized the field of image classification, surpassing human-level


performance in many tasks. They are designed to mimic the visual processing capabil-
ities of the human brain, effectively extracting meaningful features from images. By
employing multiple layers of convolutional filters, CNNs can learn hierarchical repre-
sentations of image data, enabling them to capture intricate patterns and structures. The
availability of large-scale dermatoscopic image datasets has facilitated the development
of robust CNN models for skin cancer detection.

In this project, a comprehensive dataset of dermatoscopic images is utilized, pre-


processed to remove noise and enhance image quality. The dataset contains labeled
images, annotated by expert dermatologists, ensuring accurate ground truth for training
and evaluation. A customized CNN architecture is designed, considering the unique
characteristics of skin lesions and the complexity of differentiating between malignant
and benign cases. The network is trained using advanced optimization techniques to
CHAPTER 1. INTRODUCTION Enter roll number here

maximize performance. Evaluation of the developed CNN model is carried out using
standard metrics, helping dermatologists gain insights into the model’s decision-making
process and increasing trust in its predictions.

To facilitate seamless integration into clinical workflows, a user-friendly interface is


developed, allowing dermatologists to interact with the system efficiently. The goal is
to create a practical tool that can be readily adopted by dermatologists, enhancing their
diagnostic capabilities and supporting their decision-making processes. By developing
a skin cancer detection system using CNNs, this project contributes to the ongoing ef-
forts in leveraging technology for early detection and management of skin cancer. The
potential benefits of this automated approach include improved efficiency, reduced sub-
jectivity, and enhanced accuracy in skin cancer diagnosis. The proposed system aims to
complement dermatologists’ expertise, enabling timely interventions and contributing
to proactive healthcare practices in combating skin cancer.

1.1 LITERATURE REVIEW

There have been related works done in the past to detect skin diseases using machine
learning and deep learning. Catarina Barata and Jorge S. Marques [Barata2019] con-
ducted a study on using deep learning for diagnosis of skin cancer by employing hier-
archical architectures. They discovered that skin lesions are organized in a hierarchical
way, which is taken into account by dermatologists when diagnosing them. However,
automatic systems do not make use of this information, performing the diagnosis in a
one-vs.-all approach, where all types of lesions are considered. In the survey they pro-
posed to mimic the medical strategy and train a deep-learning architecture to perform a
hierarchical diagnosis. Their results highlight the benefits of addressing the classifica-
tion of dermoscopy images in a structured way. Additionally, they provide an extensive
evaluation of criteria that must be taken into account in the development of diagnostic
systems based on deep learning.

Le Thu Thao and Nguyen Hong Quang [Thao 2017] conducted a study on auto-
matic skin lesion analysis towards melanoma detection. Deep learning methods for
image analysis have shown impressive performance in recent years. The survey pre-

Department of ECE, IIITDM Kancheepuram, May 2021 2


CHAPTER 1. INTRODUCTION Enter roll number here

sented deep learning based approaches to solve two problems in skin lesion analysis us-
ing a dermoscopic image containing skin tumor. The proposed models are trained and
evaluated on standard benchmark datasets from the International Skin Imaging Collab-
oration (ISIC) 2017 Challenge, which consists of 2000 training samples and 600 testing
samples. The result shows that the proposed methods achieve promising performance.

Jainesh Rathod et al. [Rathod2018] conducted a study on the diagnosis of skin


diseases using convolutional neural networks. This survey suggests that dermatology is
one of the most unpredictable and difficult terrains to diagnose due its complexity. In the
field of dermatology, many a times extensive tests are to be carried out so as to decide
upon the skin condition the patient may be facing. The time may vary from practitioner
to practitioner. This is also based on the experience of that person too. So, there is a
need of a system which can diagnose the skin diseases without any of these constraints.
They proposed an automated image-based system for recognition of skin diseases using
machine learning classification. This system will utilize a computational technique to
analyze, process and relegate image data based on various features of the images. Skin
images are filtered to remove unwanted noise and also process it for enhancement of
the image. Feature extraction using complex techniques such as Convolutional Neural
Network (CNN), classify the image based on the algorithm of SoftMax classifier and
obtain the diagnosis report as an output. This system will give greater accuracy and
generate results faster than the traditional method, making this application an efficient
and reliable system for the detection of dermatological diseases. Furthermore, this can
also be used as a reliable real-time teaching tool for medical students in the dermatology
stream.

1.2 MOTIVATION

Skin cancer is an alarming issue and it must be detected as early as possible. The
diagnostic is a manual process that is time consuming as well as expensive. But, today’s
world science has become advanced by using machine learning and it can be helpful in
many ways. Hence, machine learning can make easy for detecting cancerous cells and
that is why machine learning specially convolutional neural network is used to detect

Department of ECE, IIITDM Kancheepuram, May 2021 3


CHAPTER 1. INTRODUCTION Enter roll number here

cancerous cell more quickly, and efficiently.

Melanoma incidence rates have risen dramatically in recent decades, and although
the majority of people diagnosed with skin cancer have a better chance of being cured,
melanoma survival rates are lower than non-melanoma skin cancer survival rates. Melanoma
skin cancer (MSC) can develop on any skin surface and been on the increasing in many
parts of the globe for the past two decades. Men’s heads, necks, and between the hips
and shoulders are the most common spots, while women’s lower legs or between the
shoulders and hips are most popular spots. When it does occur in dark skinned people,
it is usually found under the toe nails, toenails, palms, or toes.

Table 1.1: A sample table

Col1 Col2 Col2 Col3


1 6 87837 787
2 7 78 5415
3 545 778 7507
4 545 18744 7560
5 88 788 6344

Department of ECE, IIITDM Kancheepuram, May 2021 4


CHAPTER 2

METHODOLOGY

2.1 PROBLEM STATEMENT

The current system is a time-consuming process that is difficult to identify in its early
stages because signs do not occur until the later stages. Implementation of a method to
simplify the classification process in order to detect skin cancer early.

2.2 EXISTING SYSTEM


• Skin self-examination: This involves regularly checking your skin for any new or
changing moles or lesions. This method can be effective in detecting early signs
of skin cancer, but it relies on the individual being able to recognize the changes
and seek medical attention if necessary.

• Dermoscopy: This is a non-invasive method of examining skin lesions using a


special magnifying tool called a dermoscope. Dermoscopy allows dermatologists
to visualize the structures and patterns within skin lesions that are not visible to
the naked eye, and can help to distinguish between benign and malignant lesions.

• Biopsy: A skin biopsy involves removing a small sample of skin for laboratory
analysis. There are several types of skin biopsy, including punch biopsy, shave
biopsy, and excisional biopsy. Biopsy is the most accurate way to diagnose skin
cancer and determine its type and stage.

• Artificial intelligence (AI): AI algorithms can be trained to analyze images of


skin lesions and detect signs of skin cancer. These systems can be used to assist
dermatologists in making a diagnosis or to provide a preliminary assessment for
individuals who may not have easy access to medical care.

It’s important to note that no single method is fool proof, and a combination of
methods may be used to achieve the most accurate diagnosis. Regular skin checks
and seeking medical attention for any suspicious changes in your skin can also greatly
increase the likelihood of detecting skin cancer early, when it is most treatable.
CHAPTER 2. METHODOLOGY Enter roll number here

2.3 PROPOSED SYSTEM

Here for skin lesion/cancer classification, dermoscopic images were employed to Deep
CNN architecture to extract deep features for classification of melanoma into can-
cer/malignant type and benign/non- cancerous type.

The perception of skin disease is accomplished through two phases. Phase I involves
collection and preprocessing of dataset and the training phase and the testing phase of
the developed Deep CNN model. Phase II includes real time implementation and visu-
alization of result in GUI. Since one of the factors that determines the accuracy of pre-
diction is the database, we combined at least six different databases (available online)
which is collected by different physicians / researchers / medical students / pathologists
/ competitions. Also, for each image in the database, the manual segmentation and
the clinical diagnosis of the skin lesion as well as the identification of other important
dermoscopic criteria is available. These dermoscopic criteria include the assessment
of the lesion asymmetry, and also the identification of colors and several differential
structures, such as pigment network, dots, globules, streaks, regression areas and blue
whitish veil. There are several datasets like International Skin Imaging Collaboration
(ISIC) 2018 Challenge, HAM10000, Benign vs. Malignant and PH2. The images col-
lected from dataset Benign vs. Malignant was divided into training and testing set in
the ratio 8:2. Each image in the dataset undergoes a preprocessing part, which involves
rescaling of image and labeling of image. Label ’0’ is assigned for benign class and ‘1’
is assigned for malignant class.

Department of ECE, IIITDM Kancheepuram, May 2021 6


CHAPTER 3

WORK DONE

3.1 DERMATOLOGICAL IMAGES AND DATASETS

High-quality images of skin diseases are important for both dermatologists and auto-
mated diagnostic systems. On the one hand, dermatologists rely on high-resolution
(HR) images to make diagnoses when direct observation is impossible. This is espe-
cially common in telemedicine, medical consultations, and regular clinics. On the other
hand, training reliable algorithms has always necessitated the use of high-quality data.
In particular, deep learning algorithms always need a vast volume of labeled data for
a better accuracy. As a result, high-quality dermatological images are critical for both
clinical diagnosis and the design of new algorithms. In this section, we go over three
different types of images commonly used in skin cancer diagnosis, as well as some
public datasets.

3.1.1 Dermatological Images

The three main types of image modalities used to diagnose skin diseases are clini-
cal images, dermoscopy images, and histopathological images (see Figure 1). Clinical
images are frequently captured by mobile devices for remote diagnosis or as medical
records. Dermoscopy images and histopathological images are commonly utilized in
clinical diagnosis to assess the severity of the illness. In the next part, we introduce
them separately.

3.1.2 Dataset

To create a trustworthy and robust skin cancer classification system, a variety of datasets
with all kinds of dermatological images are required. As the need for medical imaging
CHAPTER 3. WORK DONE Enter roll number here

resources in academia grows, more and more datasets are becoming publicly available.
To provide readers with a reference, we introduce several commonly used skin disease
datasets in the next part, along with the works based on these datasets.

3.1.3 Benign vs Malignant

A benign vs. malignant dataset is a collection of images or data that is specifically


curated and labeled to distinguish between benign (non-cancerous) and malignant (can-
cerous) cases. These datasets are commonly used in the field of medical image analysis
and machine learning for training and evaluating algorithms aimed at automatic de-
tection classification of skin lesions or tumors. The dataset typically consists of 3300
images or samples of different skin lesions, along with corresponding labels indicating
whether each case is benign or malignant. The images may be captured through various
imaging modalities such as photography, dermoscopy, or histopathology.

The purpose of creating such a dataset is to provide a standardized and representa-


tive set of examples that cover a wide range of benign and malignant cases. This enables
researchers, developers, and healthcare professionals to train machine learning models
or algorithms to accurately classify and differentiate between benign and malignant skin
lesions or tumors. These datasets are valuable for developing computer-aided diagnosis
systems, decision support tools, and other automated methods for skin cancer detection.
By training algorithms on these datasets, researchers can evaluate the performance and
accuracy of their models and potentially improve early detection and diagnosis of skin
cancer.

3.1.4 Data Collection

In order to effectively classify images, the choice of dataset is crucial. We have carefully
selected the Benign vs. Malignant Dataset due to its comprehensive nature, containing
a total of 3300 images. This dataset is divided into two classes, benign and malignant,
with a split of 8:2 for training and testing respectively. As part of our preprocessing
stage, each image is rescaled and labelled for ease of classification. The benign class
is assigned a ’0’ label, while the malignant class is labelled with ’1’. These measures

Department of ECE, IIITDM Kancheepuram, May 2021 8


CHAPTER 3. WORK DONE Enter roll number here

ensure accurate classification and improve the overall efficiency of the training process.

3.1.5 Digital Image Processing

Digital image processing involves manipulating and analysing digital images using var-
ious algorithms and techniques. It involves applying mathematical operations and al-
gorithms to enhance their quality, extract useful information, or perform specific tasks.
This process can be performed on images captured by digital cameras, scanned doc-
uments, medical images, and satellite images. The process typically involves several
steps, including image acquisition, pre-processing, image enhancement, restoration,
compression, segmentation, feature extraction, object detection and recognition, and
image analysis.

Digital image processing finds applications in various fields, such as medical imag-
ing, remote sensing, surveillance, robotics, quality control, forensic analysis, and more.
It plays a crucial role in extracting meaningful insights and facilitating decision mak-
ing processes from visual data. Techniques like template matching, machine learning
algorithms, and deep learning methods are used to achieve these tasks.

In conclusion, digital image processing plays a crucial role in various fields, such
as medical imaging, remote sensing, surveillance, robotics, quality control, and foren-
sic analysis, by enhancing the quality, extracting useful information, and facilitating
decision making processes.

3.1.6 Study Selection

We limited our review to skin lesion classification methods. In particular, methods that
apply a CNN only for lesion segmentation or for the classification of dermatoscopic
patterns are considered in this paper. Furthermore, only papers that show a sufficient
scientific proceeding are included in this review. This latter criterion includes presenting
the approaches in an understandable manner and discussing the results sufficiently.

Department of ECE, IIITDM Kancheepuram, May 2021 9


CHAPTER 3. WORK DONE Enter roll number here

3.2 CONVOLUTIONAL NEURAL NETWORK

A Convolutional Neural Network (CNN) is a type of Deep Learning neural network


architecture commonly used in Computer Vision. Computer vision is a field of Artifi-
cial Intelligence that enables a computer to understand and interpret the image or visual
data. one of the strengths of neural networks is that they are capable of learning pattern
features directly from training data. What we would like to do is input a set of training
images directly into a neural network, and have the network learn the necessary fea-
tures on its own. One way to do this would be to convert images to vectors directly
by organizing the pixels based on a linear index , and then letting each element (pixel)
of the linear index be an element of the vector. However, this approach does not uti-
lize any spatial relationships that may exist between pixels in an image, such as pixel
arrangements into corners, the presence of edge segments, and other features that may
help to differentiate one image from another. Convolutional neural networks (CNNs or
ConvNets), is a class of neural networks that accept images as inputs and are ideally
suited for automatic learning and image classification.

3.2.1 CNN Architecture

A key difference between this architecture and the neural net architectures is that inputs
to CNNs are 2-D arrays (images), while inputs to the fully connected neural networks
are vectors. However the computations performed by both networks are very similar
a sum of products is formed, a bias value is added, the result is passed through an
activation function, and the activation value becomes a single input to a following layer.
There are some basic differences between the two, beyond their input formats being
2-D versus vectors. An important difference is that CNNs are capable of learning 2-D
features directly from raw image data, a system that can learn image features from raw
image data is a crucial advantage of CNNs. Another major difference is in the way
in which layers are connected. In a fully connected neural net, we feed the output of
every neuron in a layer directly into the input of every neuron in the next layer, while in
CNN we feed into every input of a layer, a single value, determined by the convolution
(hence the name convolutional neural net) over a spatial neighbourhood in the output of

Department of ECE, IIITDM Kancheepuram, May 2021 10


CHAPTER 3. WORK DONE Enter roll number here

the previous layer. Another difference is that the 2-D arrays from one layer to the next
are subsampled to reduce sensitivity to translational variations in the input.

There are two main parts to a CNN architecture

• A convolution tool that separates and identifies the various features of the image
for analysis in a process called as Feature Extraction. The network of feature
extraction consists of many pairs of convolutional or pooling layers.

• A fully connected layer that utilizes the output from the convolution process and
predicts the class of the image based on the features extracted in previous stages.

This CNN model of feature extraction aims to reduce the number of features present
in a dataset. It creates new features which summarises the existing features contained
in an original set of features. There are many CNN layers as shown in the CNN archi-
tecture diagram.

Figure 3.1: CNN Architecture

3.2.2 Layers

There are three types of layers that make up the CNN which are the convolutional
layers, pooling layers, and fully-connected (FC) layers. When these layers are stacked,
a CNN architecture will be formed. In addition to these three layers, there are two more
important parameters which are the dropout layer and the activation function which are
defined below

Department of ECE, IIITDM Kancheepuram, May 2021 11


CHAPTER 3. WORK DONE Enter roll number here

1. Convolutional Layer : This layer is the first layer that is used to extract the various
features from the input images. In this layer, the mathematical operation of convolution
is performed between the input image and a filter of a particular size MxM. By sliding
the filter over the input image, the dot product is taken between the filter and the parts
of the input image with respect to the size of the filter (MxM). The output is termed as
the Feature map which gives us information about the image such as the corners and
edges. Later, this feature map is fed to other layers to learn several other features of the
input image.

The convolution layer in CNN passes the result to the next layer once applying the
convolution operation in the input. Convolutional layers in CNN benefit a lot as they
ensure the spatial relationship between the pixels is intact.

Figure 3.2: Convolutional Layer of CNN

2. Pooling Layer : In most cases, a Convolutional Layer is followed by a Pooling


Layer. The primary aim of this layer is to decrease the size of the convolved feature
map to reduce the computational costs. This is performed by decreasing the connec-
tions between layers and independently operates on each feature map. Depending upon
method used, there are several types of Pooling operations. It basically summarizes the
features generated by a convolution layer.

In Max Pooling, the largest element is taken from feature map. Average Pooling
calculates the average of the elements in a predefined sized Image section. The total
sum of the elements in the predefined section is computed in Sum Pooling. The Pooling
Layer usually serves as a bridge between the Convolutional Layer and the FC Layer.

This CNN model generalises the features extracted by the convolution layer, and

Department of ECE, IIITDM Kancheepuram, May 2021 12


CHAPTER 3. WORK DONE Enter roll number here

helps the networks to recognize the features independently. With the help of this, the
computations are also reduced in a network.

Figure 3.3: Pooling Layer of CNN

3. Fully Connected Layer : The Fully Connected (FC) layer consists of the weights
and biases along with the neurons and is used to connect the neurons between two
different layers. These layers are usually placed before the output layer and form the
last few layers of a CNN Architecture.

In this, the input image from the previous layers are flattened and fed to the FC
layer. The flattened vector then undergoes few more FC layers where the mathematical
functions operations usually take place. In this stage, the classification process begins to
take place. The reason two layers are connected is that two fully connected layers will
perform better than a single connected layer. These layers in CNN reduce the human
supervision.

4. Dropout : Usually, when all the features are connected to the FC layer, it can
cause overfitting in the training dataset. Overfitting occurs when a particular model
works so well on the training data causing a negative impact in the model’s performance
when used on a new data.

To overcome this problem, a dropout layer is utilized wherein a few neurons are
dropped from the neural network during training process resulting in reduced size of
the model. On passing a dropout of 0.3, 30 percentage of the nodes are dropped out
randomly from the neural network.

Dropout results in improving the performance of a machine learning model as it


prevents overfitting by making the network simpler. It drops neurons from the neural

Department of ECE, IIITDM Kancheepuram, May 2021 13


CHAPTER 3. WORK DONE Enter roll number here

Figure 3.4: Fully Connected Layer of CNN

networks during training.

Department of ECE, IIITDM Kancheepuram, May 2021 14


CHAPTER 3. WORK DONE Enter roll number here

5. Activation Functions : One of the most important parameters of the CNN model
is the activation function. They are used to learn and approximate any kind of contin-
uous and complex relationship between variables of the network. In simple words, it
decides which information of the model should fire in the forward direction and which
ones should not at the end of the network.

It adds non-linearity to the network. There are several commonly used activation
functions such as the ReLU, Softmax, tanH and the Sigmoid functions. Each of these
functions have a specific usage. For a binary classification CNN model, sigmoid and
softmax functions are preferred an for a multi-class classification, generally softmax us
used. In simple terms, activation functions in a CNN model determine whether a neuron
should be activated or not. It decides whether the input to the work is important or not
to predict using mathematical operations.

Figure 3.5: Dropout Layer of CNN

3.2.3 Operations of CNN

The type of neighbourhood processing in CNNs is spatial convolution. Convolution


is an operation on two functions f and g, which produces a third function that can be
interpreted as a modified ("filtered") version of f. In the interpretation we call g the

Department of ECE, IIITDM Kancheepuram, May 2021 15


CHAPTER 3. WORK DONE Enter roll number here

filter. If f is defined on a spatial variable like x rather than a time variable like t, we call
the operation spatial convolution. Convolution lies at the heart of any physical device
or computational procedure that performs smoothing or sharpening. Applied to two
dimensional functions like images, it’s also useful for edge finding, feature detection,
motion detection, image matching, and countless other tasks. convolution computes a
sum of products between pixels and a set of kernel weights. This operation is carried
out at every spatial location in the input image. The result at each location (x, y) in the
input is a scalar value. Value is the output of a neuron in a layer of a fully connected
neural net. If we add a bias and pass the result through an activation function, we have
a complete analogy between the basic computations performed by a CNN and those
performed by the neural nets.

In CNN terminology, the neighbourhoods are called receptive fields. All a receptive
field does is select a region of pixels in the input image. The first operation performed
by a CNN is convolution, whose values are generated by moving the receptive field
over the image and, at each location, forming a sum of products of a set of weights and
the pixels contained in the receptive field. The set of weights, arranged in the shape of
the receptive field, is a kernel. The number of spatial increments by which a receptive
field is moved is called the stride. In CNNs, an important motivations for using strides
greater than one is data reduction. For example, changing the stride from one to two
reduces the image resolution by one-half in each spatial dimension, resulting in a three-
fourths reduction in the amount of data per image. Another important motivation is
as a substitute for subsampling which is used to reduce system sensitivity to spatial
translation.

To each convolution value (sum of products) we add a bias, then pass the result
through an activation function to generate a single value. Then, this value is fed to
the corresponding (x, y) location in the input of the next layer. When repeated for all
locations in the input image, the process just explained results in a 2-D set of values
that we store in next layer as a 2-D array, called a feature map. This terminology is
motivated by the fact that the role performed by convolution is to extract features such
as edges, points, and blobs from the input. The same weights and a single bias are
used to generate the convolution (feature map) values corresponding to all locations

Department of ECE, IIITDM Kancheepuram, May 2021 16


CHAPTER 3. WORK DONE Enter roll number here

of the receptive field in the input image. This is done to cause the same feature to be
detected at all points in the image. Using the same weights and bias for this purpose
is called weight (or parameter) sharing. The other feature maps are generated using a
different set of weights and bias for each feature map. Because each set of weights and
bias is different, each feature map generally will contain a different set of features, all
extracted from the same input image. The feature maps are referred to collectively as a
convolutional layer.

The process after convolution and activation is subsampling (also called pooling),
which is motivated by a model of the mammal visual cortex proposed by Hubel and
Wiesel [1959]. Their findings suggest that parts of the visual cortex consist of simple
and complex cells. The simple cells perform feature extraction, while the complex cells
combine (aggregate) those features into a more meaningful whole. Pooling is a way
of modelling of reduction in dimensionality. When training a CNN with large image
databases, pooling has the additional advantage of reducing the volume of data being
processed. You can think of the results of subsampling as producing pooled feature
maps. In other words, a pooled feature map is a feature map of reduced spatial reso-
lution. Pooling is done by subdividing a feature map into a set of small (typically 2×2
) regions, called pooling neighbourhoods, and replacing all elements in such a neigh-
bourhood by a single value. We assume that pooling neighbourhoods are adjacent (i.e.,
they do not overlap). There are several ways to compute the pooled values; collectively,
the different approaches are called pooling methods.

Three common pooling methods are:

1. Average pooling, in which the values in each neighborhood are replaced by the
average of the values in the neighborhood;

2. Max-pooling, which replaces the values in a neighborhood by the maximum


value of its elements; and

3. L2 pooling, in which the resulting pooled value is the square root of the sum
of the neighborhood values squared. There is one pooled feature map for each feature
map. The pooled feature maps are referred to collectively as a pooling layer. The use of
receptive fields, convolution, parameter sharing, and pooling are characteristics unique

Department of ECE, IIITDM Kancheepuram, May 2021 17


CHAPTER 3. WORK DONE Enter roll number here

to CNNs.

Because feature maps are the result of spatial convolution they are simply filtered
images. It then follows that pooled feature maps are filtered images of lower resolution.
The pooled feature maps in the first layer become the inputs to the next layer in the
network.

But, whereas we showed a single image as an input to the first layer, we now have
multiple pooled feature maps (filtered images) that are inputs into the second layer. To
see how these multiple inputs to the second layer are handled, focus for a moment on
one pooled feature map. To generate the values for the first feature map in the second
convolutional layer, we perform convolution, add a bias, and use activation, as before.
Then, we change the kernel and bias, and repeat the procedure for the second feature
map, still using the same input. We do this for every remaining feature map, changing
the kernel weights and bias for each.

Then, we consider the next pooled feature map input and perform the same proce-
dure (convolution, plus bias, plus activation) for every feature map in the second layer,
using yet another set of different kernels and biases. When we are finished, we will
have generated three values for the same location in every feature map, with one value
coming from the corresponding location in each of the three inputs. The question now
is: How do we combine these three individual values into one? The answer lies in the
fact that convolution is a linear process, from which it follows that the three individual
values are combined into one by superposition (that is, by adding them). In the first
layer, we had one input image and three feature maps, so we needed three kernels to
complete all required convolutions.

In the second layer, we have three inputs and seven feature maps, so the total number
of kernels (and biases) needed is 3×7=21 . Each feature map is pooled to generate a
corresponding pooled feature map, resulting in seven pooled feature maps. So these
seven pooled feature maps are the outputs of the last layer.

As usual, the ultimate objective is to use features for classification, so we need a


classifier. In a CNN we perform classification by feeding the value of the last pooled
layer into a fully connected neural net. But the outputs of a CNN are 2-D arrays (i.e.,

Department of ECE, IIITDM Kancheepuram, May 2021 18


CHAPTER 3. WORK DONE Enter roll number here

filtered images of reduced resolution), whereas the inputs to a fully connected net are
vectors.

Therefore, we have to vectorize the 2-D pooled feature maps in the last layer. We do
this using linear indexing. Each 2-D array in the last layer of the CNN is converted into
a vector, then all resulting vectors are concatenated (vertically for a column) to form a
single vector. This vector propagates through the neural net . In any given application,
the number of outputs in the fully connected net is equal to the number ofpattern classes
being classified. The output with the highest value determines the class of the input.

3.2.4 CNN vs Neural Networks

The biggest problem with regular neural networks (NNs) is a lack of scalability. For
smaller images with fewer color channels, a regular NN may produce satisfactory re-
sults. But as the size and complexity of an image increases, the need for computational
power and resources also increases which necessitates a larger and more expensive NN.

Moreover, the problem of overfitting also arises over time, wherein the NN tries to
learn too many details in the training data. It may also end up learning the noise in the
data, which affects its performance on test data sets. Ultimately, the NN fails to identify
the features or patterns in the data set and thus the object itself.

In contrast, a CNN uses parameter sharing. In each layer of the CNN, each node
connects to another. A CNN also has an associated weight; as the layers’ filters move
across the image, the weights remain fixed – a condition known as parameter sharing.
This makes the whole CNN system less computationally intensive than an NN system.

3.2.5 Benefits of using CNNs for deep learning

Deep learning is a subset of machine learning that uses neural networks with at least
three layers. Compared to a network with just one layer, a network with multiple layers
can deliver more accurate results. Both RNNs and CNNs are used in deep learning,
depending on the application.

Department of ECE, IIITDM Kancheepuram, May 2021 19


CHAPTER 3. WORK DONE Enter roll number here

Figure 3.6: The difference between CNN and RNN

For image recognition, image classification and computer vision (CV) applications,
CNNs are particularly useful because they provide highly accurate results, especially
when a lot of data is involved. The CNN also learns the object’s features in successive
iterations as the object data moves through the CNN’s many layers. This direct (and
deep) learning eliminates the need for manual feature extraction (feature engineering).

CNNs can be re-trainedd for new recognition tasks and built on pre-existing net-
works. These advantages open up new opportunities to use CNNs for real-world appli-
cations without increasing computational complexities or costs. As seen earlier, CNNs
are more computationally efficient than regular NNs since they use parameter sharing.
The models are easy to deploy and can run on any device.

3.2.6 Applications of Convolutional Neural Network

Convolutional Neural Networks (CNNs) have found numerous applications across var-
ious domains. Here are some elaborations on the applications of CNNs:

1. Image Classification: CNNs excel at image classification tasks, such as identi-

Department of ECE, IIITDM Kancheepuram, May 2021 20


CHAPTER 3. WORK DONE Enter roll number here

fying objects within images. They learn to automatically extract relevant features from
images through convolutional layers, enabling accurate classification of objects, scenes,
or patterns.

2. Object Detection: CNNs can be used to detect and localize objects within images.
They provide bounding box coordinates around objects, allowing for applications like
autonomous driving, surveillance systems, and facial recognition.

3. Semantic Segmentation: CNNs can perform pixel-level segmentation, where


each pixel in an image is classified into different classes or categories. This is useful
in applications like medical imaging, where segmenting organs or tumors is crucial for
diagnosis.

4. Image Generation: CNNs can generate realistic images. Generative Adversarial


Networks (GANs) use CNNs to generate synthetic images that resemble real images,
which find applications in art, entertainment, and data augmentation for training other
models.

5. Video Analysis: CNNs can process videos by analyzing consecutive frames.


They can track objects, recognize actions, and perform video classification tasks. Ap-
plications include video surveillance, sports analytics, and video content understanding.

6. Natural Language Processing (NLP): CNNs have been applied to NLP tasks,
such as text classification, sentiment analysis, and named entity recognition. CNNs
can capture local patterns within sequences of words, providing valuable insights for
language processing. 7. Speech Recognition: CNNs have been employed for speech
recognition tasks, where audio signals are processed to convert spoken language into
text. CNNs help in identifying phonetic patterns and improving speech-to-text accuracy.

8. Medical Diagnosis: CNNs have shown great potential in medical imaging for di-
agnosing diseases, such as cancer detection from mammograms or identifying anoma-
lies in MRI scans. They help automate the interpretation of medical images, assisting
healthcare professionals in diagnosis.

9. Autonomous Vehicles: CNNs are crucial in enabling autonomous vehicles to


perceive and understand their surroundings. They can detect and classify objects, rec-
ognize traffic signs, and provide real-time analysis for safe navigation.

Department of ECE, IIITDM Kancheepuram, May 2021 21


CHAPTER 3. WORK DONE Enter roll number here

10. Robotics: CNNs are used in robotics for object recognition, grasping, and ma-
nipulation. They enable robots to perceive the environment, recognize objects, and
make informed decisions based on visual input.

These are just a few examples of the wide range of applications where CNNs have
demonstrated their effectiveness. CNNs continue to advance and find applications in
various fields, driven by their ability to extract meaningful features from complex data.

Department of ECE, IIITDM Kancheepuram, May 2021 22


CHAPTER 3. WORK DONE Enter roll number here

3.3 SYSTEM REQUIREMENTS and LIBRARIES

3.3.1 Hardware requirements (Recommended)


• Computer with i5 / Ryzen 5 processor or above

• Minimum 6GB RAM

• 2GB GPU

3.3.2 Software requirements


• Operating System : Windows, Mac OS, Linux

• Application : VS Code with Python 2.0 or above

Visual Studio Code

Visual Studio Code is a Microsoft source-code editor based on the Electron Framework,
available for Windows, Linux, and macOS. It offers features such as debugging, syntax
highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.
Users can customize themes, keyboard shortcuts, preferences, and install extensions
to enhance functionality. Visual Studio Code is the most popular tool for developing
environments among 71,010 respondents, with 74.48 percentage using it. It supports
various programming languages, including C, C, C++, Fortran, Go, Java, JavaScript,
[Link], Python, Rust, and Julia.

Out of the box, Visual Studio Code includes basic support for most common pro-
gramming languages, including syntax highlighting, bracket matching, code folding,
and configurable snippets. It also includes IntelliSense for JavaScript, TypeScript,
JSON, CSS, and HTML, as well as debugging support for [Link]. Additional lan-
guages can be added through freely available extensions on the VS Code Marketplace.
Visual Studio Code is language-agnostic, allowing users to open directories and save
them in workspaces for future reuse. It can be extended via extensions available through
a central repository, including support for new languages, themes, debuggers, static
code analysis, and code linters using the Language Server Protocol.

Department of ECE, IIITDM Kancheepuram, May 2021 23


CHAPTER 3. WORK DONE Enter roll number here

Source control is a built-in feature, allowing users to access version control settings
and view changes made to the current project. It requires linking to a supported version
control system, allowing users to create repositories and push and pull requests directly
from the program. Visual Studio Code supports multiple FTP extensions, allowing
users to set the code page, newline character, and programming language for active
documents.

Visual Studio Code collects usage data and sends it to Microsoft, but this can be dis-
abled. The open-source nature of the application allows the public to see the collected
data.

Python

Python is a high-level, interpreted, interactive, and object-oriented scripting that is de-


signed to be highly readable and readable. It uses English keywords frequently and
has fewer syntactical constructions than other languages. Python is processed at run-
time by the interpreter, making it easy to write programs without compiling them. It is
also interactive, allowing users to interact with the interpreter directly. Python supports
Object-Oriented style, encapsulating code within objects.

Developed by Guido van Rossum in the late eighties and early nineties at the Na-
tional Research Institute for Mathematics and Computer Science in the Netherlands,
Python is derived from various languages, including ABC, Modula-3, C, C++, Algol-
68, SmallTalk, and Unix shell. It is copyrighted and is maintained by a core develop-
ment team at the institute.

Python’s features include being easy-to-learn, easy-to-read, easy-to-maintain, a broad


standard library, interactive mode, portability, extensibility, databases, GUI program-
ming, and scalability. It supports functional and structured programming methods,
OOP, and can be used as a scripting language or compiled to byte-code for large ap-
plications. It also provides high-level dynamic data types and supports dynamic type
checking. Python is easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Department of ECE, IIITDM Kancheepuram, May 2021 24


CHAPTER 3. WORK DONE Enter roll number here

3.3.3 Libraries Used

OpenCV Numpy Tensorflow Keras Matplotlib Sklearn Tkinter Pillow

OpenCV

OpenCV is a popular Python library for computer vision and image processing, offer-
ing a wide range of functions and algorithms for various tasks. It includes computer
vision algorithms for object detection, feature extraction, image segmentation, opti-
cal flow, and camera calibration. OpenCV supports various image formats, such as
JPEG, PNG, and BMP, and supports image transformation and geometric operations. It
also provides feature detection and description algorithms, such as Harris corner detec-
tion, SIFT, SURF, and ORB. OpenCV integrates with other libraries and frameworks,
enabling tasks like image classification, object detection, and semantic segmentation
using trained models.

The library also provides a graphical user interface (GUI) for creating windows, dis-
playing images or videos, handling mouse and keyboard events, and drawing shapes or
annotations. OpenCV is designed for efficiency and can take advantage of multi-core
processors, leveraging CPU capabilities for faster execution and hardware accelera-
tion with frameworks like CUDA. The large and active community of OpenCV users
provides support and examples for various computer vision tasks, making it a popular
choice for image processing and computer vision applications in Python.

import cv2 as cv

Numpy

NumPy is an open-source library for numerical computing in Python, offering effi-


cient multidimensional array operations, mathematical functions, and tools for work-
ing with large datasets. Its main feature is the ndarray (N-dimensional array) object,
which allows efficient storage and manipulation of homogeneous data. NumPy pro-
vides a comprehensive set of mathematical functions for array operations, including
basic arithmetic operations, trigonometry, logarithms, exponential calculations, statis-

Department of ECE, IIITDM Kancheepuram, May 2021 25


CHAPTER 3. WORK DONE Enter roll number here

tical functions, and linear algebra. It also supports array broadcasting, allowing oper-
ations between arrays of different shapes. NumPy also offers powerful indexing and
slicing capabilities for accessing and manipulating array elements.

NumPy offers a wide range of array operations, including element-wise operations,


matrix operations, and linear algebra functions. It seamlessly integrates with the Python
programming language and works well with other scientific Python libraries like mat-
plotlib and pandas. Its array-based approach to numerical computing makes it highly
efficient in terms of performance and memory usage. NumPy also provides functions
for reading and writing arrays from/to files in various formats, making it easy to store
and share numerical data.

NumPy has a large and active community, with extensive documentation, tutorials,
and resources available. It serves as the foundation for many other scientific comput-
ing libraries in Python, such as SciPy, pandas, and scikit-learn, forming a powerful
ecosystem for data analysis and scientific computing. Overall, NumPy is a fundamen-
tal library for numerical computing in Python, offering versatile and efficient tools for
various scientific and data-related tasks.

import numpy as np

Tensorflow

Google’s open-source TensorFlow machine learning package is used to create and train
neural networks. It provides a robust framework for building and refining neural net-
works, with tensors serving as the main data structure. A huge developer community,
pre-trained models, automatic differentiation, GPU acceleration, eager execution, and
pretrained models are all supported by TensorFlow. While TensorBoard is a web-based
tool for visualising and analysing TensorFlow operations, TensorFlow Hub offers pre-
trained models for a variety of workloads. Additionally, TensorFlow provides a number
of deployment options, such as exporting models to platforms like TensorFlow Saved-
Model or TensorFlow Lite for mobile and embedded devices, as well as integrating
with TensorFlow Serving for scalable model serving in production settings. Tensor-
Flow is a well-liked option for both research and production applications because of its

Department of ECE, IIITDM Kancheepuram, May 2021 26


CHAPTER 3. WORK DONE Enter roll number here

ecosystem and community.

import tensorflow as tf

Keras

Keras is a popular open-source deep learning library written in Python, offering a user-
friendly API for building and training neural networks. It supports various neural net-
work architectures, including feedforward networks, convolutional neural networks,
and recurrent neural networks. Keras also allows easy model customization, with pre-
trained models and transfer learning options. Model training and evaluation are straight-
forward, with optimizers, loss functions, and metrics to configure the training process.
Keras supports callbacks to customize the training process. It seamlessly integrates with
deep learning libraries like TensorFlow and Theano, enabling faster model training and
inference.

Model deployment is made easier with model export to various formats, such as
TensorFlow SavedModel, TensorFlow Lite, and ONNX. Keras integrates with Tensor-
Flow, combining the high-level simplicity of Keras with the low-level flexibility of Ten-
sorFlow.

Keras has a large and active developer community, offering documentation, tutori-
als, and resources to support learning and development. It also integrates with popular
libraries and frameworks in the Python ecosystem, such as NumPy and scikit-learn,
providing a rich set of tools for deep learning and data analysis. Overall, Keras is a
powerful and user-friendly deep learning library for Python, making it a popular choice
for both beginners and experienced practitioners.

from tensorflow import keras

Matplotlib

Matplotlib is a powerful open-source library for creating visualizations and plots in


Python. It offers a variety of plotting functions, an object-oriented interface, and ex-
tensive customization options for plots. Users can create Figure and Axes objects to

Department of ECE, IIITDM Kancheepuram, May 2021 27


CHAPTER 3. WORK DONE Enter roll number here

represent the overall plot and individual subplots, modify colors, line styles, marker
types, and sizes, and annotate plots with text, arrows, and shapes. Matplotlib also al-
lows for multiple subplots within a single figure, allowing for side by side or grid layout
visualizations.

Matplotlib saves and exports plots as image files in various formats, including PNG,
JPEG, PDF, and SVG. It seamlessly integrates with NumPy, a popular library for nu-
merical computing in Python, and supports different backends for plotting. Matplotlib
also integrates with Pandas, a powerful data manipulation and analysis library, allowing
users to directly plot Pandas DataFrames and Series using Matplotlib.

Matplotlib’s large and active community provides extensive documentation, tuto-


rials, and examples, making it a foundational library for data visualization in Python.
It has inspired the development of additional visualization libraries like Seaborn and
Plotly, which build on top of Matplotlib. Overall, Matplotlib is a versatile and powerful
tool for data exploration, analysis, and presentation.

import [Link] as plt

Sklearn

Scikit-learn is an open-source machine learning library for Python that offers a variety
of tools and algorithms for various tasks, including classification, regression, cluster-
ing, dimensionality reduction, and model selection. It provides a unified interface for
accessing and using various machine learning algorithms, data preprocessing and fea-
ture engineering, model selection and evaluation, pipelines and workflow simplifica-
tion, integration with NumPy and Pandas, handling imbalanced data, text mining and
natural language processing (NLP), and a large and active community. Scikit-learn is
widely used in academia and industry, and integrates well with other popular Python
libraries like NumPy, Pandas, and Matplotlib, creating a comprehensive ecosystem for
data analysis and machine learning. The library’s simplicity, consistency, and extensive
functionality make it a powerful tool for both beginners and experienced practitioners
in the field of machine learning and data analysis.

import sklearn

Department of ECE, IIITDM Kancheepuram, May 2021 28


CHAPTER 3. WORK DONE Enter roll number here

Tkinter

Tkinter is a Python library designed for creating graphical user interfaces (GUIs) with a
user-friendly interface. It offers a wide range of widgets, including buttons, labels, text
entry fields, check buttons, radio buttons, list boxes, and more, which can be arranged
and organized using layout managers. Tkinter is cross-platform compatible, allowing
applications to run seamlessly on Windows, macOS, and Linux without additional in-
stallations. Tkinter follows an event-driven programming paradigm, allowing for the
association of functions or methods with events. Customization and styling options al-
low users to change properties, colors, fonts, sizes, and alignments to match the desired
appearance and feel of their application.

Geometry management is available through three main geometry managers: ‘pack‘,


‘grid‘, and ‘place‘. Tkinter also includes pre-built dialog boxes and message boxes to
simplify common interactions with users. Tkinter integrates well with other Python
libraries, allowing for the combination of GUI capabilities with external modules like
Matplotlib for plot embedding or database-driven GUI applications. The active com-
munity of developers and users contributes to Tkinter’s development and provides re-
sources for learning and utilizing its features. Overall, Tkinter is a versatile and beginner-
friendly tool for creating interactive applications with a visually appealing interface.

from tkinter import *

Pillow

Pillow is a popular Python library for image processing and manipulation, offering var-
ious functions and methods for various operations on images. It supports image han-
dling, basic image operations, image filtering and enhancement, image manipulation,
geometric transformations, image analysis, image file metadata, and integration with
NumPy. Pillow allows users to open, create, save, and display various image file for-
mats, such as JPEG, PNG, BMP, TIFF, and GIF. It also supports image filtering and
enhancement techniques, such as blurring, sharpening, edge detection, and noise reduc-
tion.

Department of ECE, IIITDM Kancheepuram, May 2021 29


CHAPTER 3. WORK DONE Enter roll number here

Image manipulation allows users to manipulate individual pixels or regions, apply


color transformations, blend images, and draw shapes and text. Geometric transforma-
tions, such as scaling, rotating, shearing, and perspective, alter the spatial arrangement
of pixels within an image. Image analysis features include extracting color histograms,
calculating statistics, and detecting edges and contours. Image file metadata, such as
EXIF data, can be accessed and modified.

Pillow is also cross-platform, working on Windows, macOS, and Linux, providing


consistent functionality and behaviour across different platforms. With its easy-to-use
interface and broad range of features, Pillow is suitable for both simple image editing
tasks and complex image analysis applications.

from PIL import ImageTk, Image

Department of ECE, IIITDM Kancheepuram, May 2021 30


CHAPTER 4

RESULT

4.1 IMPLEMENTATION AND TESTING

4.1.1 Proposed Architecture

Figure 4.1: The difference between CNN and RNN


CHAPTER 4. RESULT Enter roll number here

Fig.4.1 shows that the architecture is based on a sequential model, in which thein-
put layer is of RGB type, passing the images through three convolutional blocks, using
small 3 by 3 filters, including a 2D convolution operation for each block and swapping-
between them. The activation function layer as well as the other layers are equipped
with a ReLU, being a nonlinearity operation and including spatial clustering through
the use of a maximum clustering layer. This network ended with a classifier block that
consists of a single layer. When the final output layer is fully connected, it performs a
binary categorization and a sigmoid activation function.

Here the complete system is divided into two phases where: Phase-I is for training
and testing of the model. Pre-processed images from the training set and features ex-
tracted through convolution, pooling, and ReLU layers. The network has three hidden
layers, with global average pooling and three dense layers. The neural network archi-
tecture consists of three main layers: Convolutional Layers, Pooling Layers, and Dense
Layer. Testing the model involves inserting test data, preprocessing it, and feeding it to
the trained CNN model. The model is trained using Tensor Flow, and Keras.

In Phase-II, The interface introduces a user-friendly interface for live image upload-
ing, allowing users to upload images from device focusing on a skin patch or lesion.

The image is pre-processed and then processed using CNN architecture. The sys-
tem’s training phase runs out the results, which are displayed on a GUI. The GUI is
created using Tkinter package for creating custom pages/windows in Python.

4.1.2 Procedure

Skin cancer detection using CNN (Convolutional Neural Network) algorithm involves
the following steps:
• Data Collection: Collect a large number of images of skin lesions from different
sources such as open medical datasets, online resources or by capturing images
using a camera.
• Data Preprocessing: Pre-process the data by resizing, normalizing and applying
data augmentation techniques like rotation, flipping, and zooming to increase the
diversity of the dataset.
• Data Labeling: Label the images into categories such as benign or malignant
lesions.

Department of ECE, IIITDM Kancheepuram, May 2021 32


CHAPTER 4. RESULT Enter roll number here

• Data Splitting: Split the dataset into training, validation, and test sets to avoid
overfitting and evaluate the model’s performance.

• Model Architecture: Define the architecture of the CNN model by specifying the
number of layers, filters, activation functions, and optimizer.

• Model Training: Train the CNN model on the training dataset using the back-
propagation algorithm to adjust the weights and biases of the model.

• Model Evaluation: Evaluate the performance of the trained model on the vali-
dation dataset by calculating metrics such as accuracy, precision, recall, and F1-
score.

• Model Testing: Test the performance of the trained model on the test dataset by
predicting the labels of the test images.

• Model Deployment: Deploy the trained model in a web or mobile application to


provide skin cancer detection services to users.

Overall, the above steps form a general framework for developing a skin cancer de-
tection system using CNN algorithm. However, the specific implementation of these
steps can vary depending on the dataset, model architecture, and application require-
ments.

4.1.3 Working

In this study, the dataset used is Benign Vs Malignant. The total no of images is 3300
images consisting of 1800 images for Benign class and 1500 images for Malignant
class. The distribution of training data, validation data and testing data were 75 per-
centage, 20 percentage and 5 percentage so that the training data used were 2475 im-
ages, validation data used were 660 images and the testing data used were 165 images.
Based on architecture and table , the resolution of skin images is changed to 128 × 128
pixels as an input of the CNN model which consists of 3 hidden layers. The image is
convoluted using 3 × 3 filters on each hidden layer with the number of output channels
on each layer is 16, 32, 64 respectively. At each layer, the activation process uses ReLU
activation and Max pooling. The result of Maxpooling reduces the size of the image as
can be seen in architecture (fig.4.1) and Table.4.1 . After that, the flatten process will
change image features from 3 dimensions became 1 dimension.

Department of ECE, IIITDM Kancheepuram, May 2021 33


CHAPTER 4. RESULT Enter roll number here

The last, softmax activation function will be used to classify the condition of skin
image into two classes namely, Benign and Malignant. Here an epoch value of 100 is
provided, so that the entire training and validation set will be looped 100 times. The
first feed forward will be done by assigning random weights, and after first iteration, on
the time of back propagation weights are assigned to neurons by neglecting the neurons
that doesn’t have values (dropout) . and repeats it until epoch limit reaches. Higher the
no of Input data and epoch value. The result will be much better, with high accuracy.

Upon completion of the earlier steps, we successfully set up the model, which means
that all the necessary processed data is now available for use. Furthermore, the imported
model has been integrated into the GUI code, thus enabling us to have an entry box and
a button that facilitates the loading of an image into the interface page. This image is
tested for the existence of cancer, and the trained model that has been imported does
the evaluation. The evaluation involves a determination of whether the image contains
either malignant or non-cancerous cells.

The model summary provides a summary of the model architecture, including the
number of trainable parameters in each layer:

4.1.4 Results and Findings

In this study, 2475 training images and 660 validation images were used in the train-
ing model. The images obtained from the Benign Vs Malignant, consist of 2 classes;
Benign (normal) cells and Malignant (cancer) cells. These images were trained using
the CNN model with Adam optimizer method with a learning rate of 0.001, and use
loss categorical cross-entropy. The performance parameters measured in this study are
validation accuracy, training accuracy, validation loss and training loss. After training
with 100 iterations (epoch), it can be seen the comparison of the accuracy and loss
performance of the proposed model with Adam optimizer used in Figure 4.2.

Based on the results shown in Figure 4.2, it shows, the accuracy performance and
loss performance. This is indicated by the appearance of many spikes on the accuracy
and the loss graph. Whereas, the system continues to show an increase in accuracy at
each iteration (epoch) and the difference in accuracy between the training data and the

Department of ECE, IIITDM Kancheepuram, May 2021 34


CHAPTER 4. RESULT Enter roll number here

validation data is not much different, as well as for the system loss continues to decrease
at each iteration. This condition shows that the proposed model is not overfitting and the
system model used can recognize the condition of skin lesions with the best accuracy
performance of 99 percentage and loss of 0.0346. Confusion Matrix for system model
can be seen in Figure 4.3.

It can be seen that from 165 test images used, 130 images were successfully clas-
sified according to their class. The error occurs in 19 images on Malignant(cancer)
detected as Benign(Normal) and 16 images on Benign(Normal) detected as Malig-
nant(cancer).

After the training of images, we save the model and call the model into a code
for GUI. The detection of skin cancer is done in real-time and figure 6.4 show the
screenshot of GUI to load the image. By processing these images, there may be either
Benign cells or Malignant cell. If the image fed was found to be Benign it is shown the
figure 6.5. If it was Malignant, the result will be shown as in the figure 6.6. It is said to
be diagnosed immediately, to cure it in early stages.

Department of ECE, IIITDM Kancheepuram, May 2021 35


CHAPTER 4. RESULT Enter roll number here

Figure 4.2: Hyperparameters

Department of ECE, IIITDM Kancheepuram, May 2021 36


CHAPTER 4. RESULT Enter roll number here

Figure 4.3: Training loss and accuracy graph

Figure 4.4: Confusion Matrix

Department of ECE, IIITDM Kancheepuram, May 2021 37


CHAPTER 5

CONCLUSION AND FUTURE SCOPE

5.1 CONCLUSION

In this study, we present a comprehensive overview of the most recent breakthroughs


in deep learning algorithms for skin cancer classification. Firstly, we introduced three
different types of dermatological images used in diagnosis and some commonly used
datasets. Next, we present the applications of typical CNN based methods in skin cancer
classification. After that, we introduce several frontier problems in the skin cancer clas-
sification task, such as data imbalance and limitation, cross-domain adaptability, model
robustness, and model efficiency, along with relevant deep learning-based approaches.
Finally, we provide a summary of the entire review. Skin cancer develops as a result of
uncontrolled cell proliferation in the skin. It frequently appears on sun exposed skin.
The three major types of skin cancers are basal cell carcinoma (BCC), squamous cell
carcinoma (SCC), and melanoma. Early skin cancer classification increases the chances
of a successful treatment (refer to chapter 2 for more information).

Clinical images, dermoscopic images, and histopathological images are three com-
mon types of images used for skin disease diagnosis. Among them, the most common
forms of images are dermoscopy images. With the growing need for medical imaging
resources in academia, more and more datasets are becoming publicly available. We
list several popular datasets for skin-disease images along with works based on these
datasets.

However, compared with natural image datasets, the diversity and quantity of skin-
disease datasets are still very limited, which also brings great challenges to the auto-
matic diagnosis of skin cancer (refer to chapter 3 for more information). We choose
CNN algorithm for several existing deep learning techniques. CNNs are useful for
image recognition, classification, and computer vision applications due to their high
accuracy and ability to learn features in successive iterations. They can be retrained
CHAPTER 5. CONCLUSION AND FUTURE SCOPE Enter roll number here

for new tasks and built on pre-existing networks, making them more computationally
efficient than regular NNs. CNNs are easy to deploy and run on any device. A user can
design suitable architecture very easily and in understandable manner (refer to chapter
4 for more information).

Here the complete system is implemented on a laptop with Ryzen 5 processor, 6GB
RAM and 2GB of GPU. Only a single dataset was used to train the model. Due to the
lack of high performance computer. Around 2500 images were used to train the model.
It took 3 minutes to complete a single iteration, 5 hours 10 minutes to complete 100
iteration. Here validation accuracy of 80 ,percentage is obtained. Testing images were
also predicted correctly.

Higher the no. of iteration and the images. better the result obtained. Further re-
search and development can focus on expanding the dataset, including more diverse
skin lesion types and incorporating clinical data. Additionally, the integration of ad-
vanced techniques, such as transfer learning and ensemble methods, can enhance the
performance and generalization capabilities of the CNN model.

In conclusion, the skin cancer detection system developed using CNNs offers a
promising approach to assist dermatologists in accurate and timely diagnosis. By har-
nessing the potential of deep learning and image analysis, this project contributes to
the ongoing efforts in leveraging technology for the early detection and management of
skin cancer, ultimately improving patient outcomes and advancing proactive healthcare
practices.

5.2 Future Scope

Department of ECE, IIITDM Kancheepuram, May 2021 39


40

You might also like