BATCH 09 Project
BATCH 09 Project
BATCH 09 Project
INTRODUCTION
1.1 OVERVIEW
Skin cancer is an alarming disease among mankind. People in the USA,
Canada, and Australia have been diagnosed at the highest increasing rate over the
past few decades. Skin cancer happens due to the uneven development of
melanocytic skin cells. Among all skin cancers are deadliest. A malignant tumor is
a type of cancerous tumor that spreads and expands in a patient’s body. Many
malignant skin growths have symptoms that can be identified as precursors. A
precursor is a group of aberrant cells that may develop into cancer. Precancerous
is another term for a precursor. Some precancerous skin growths have a minimal
chance of developing into cancer, whereas others have a very high chance. The
importance of detecting and treating cancer in early malignant skin growth cannot
be overstated. For this reason, CNN is proposed in the systems of this study to
detect skin cancer. For the first time, this project achieved an accuracy of 80.3%
using deep CNN on the International Skin Imaging Collaboration (ISIC) dataset.
Although this project worked on the same dataset, this time the project is
based CNN symptomatic feature extraction. After segmenting the dermoscopic
images using the feature extraction approach, the characteristics of the skin cells
are retrieved in this work. Finally, this project got an accuracy of 89.5%. The
project has worked in many ways with CNN architecture to detect skin cancer.
Through this, the project achieved a training accuracy of 93.7% using a publicly
available data set.
1
1.2 OBJECTIVES
The primary objectives of the project "Deep Learning Models for Early
Detection and Classification of Skin Cancer" are:
⚫ Deep learning models offer the potential to enhance the accuracy of skin
cancer diagnosis compared to traditional methods
⚫ The primary aim is to develop a system capable of identifying skin cancer
at its earliest stages.
⚫ Skin cancer comes in various forms, including melanoma, basal cell
carcinoma, and squamous cell carcinoma.
⚫ Another key objective is to develop a solution that is accessible and cost-
effective, making it available to a broader range of healthcare providers
and patients.
⚫ Introducing automated systems for skin cancer detection and classification
can streamline the diagnostic process.
Goals:
The goals of the project "Deep Learning Models for Early Detection and
Classification of Skin Cancer " are:
The project aims to leverage deep learning models for the early detection
and classification of skin cancer, utilizing a combination of Convolutional
Neural Networks (CNNs), Support Vector Machines (SVMs), and Decision
Trees algorithms. The overarching goal is to enhance the accuracy and
efficiency of skin cancer diagnosis by automating the process through advanced
computational techniques. CNNs are particularly well- suited for image
recognition tasks due to their ability to extract intricate features from images,
making them ideal for analyzing dermatoscopic images of skin lesions.
2
1.3 DEEP LEARNING
Deep learning is a branch of artificial intelligence focused on training
algorithms to learn patterns from data in layered structures. It's inspired by the
brain's neural networks and excels at tasks like image and speech recognition,
natural language processing, and medical diagnostics. Deep learning
algorithms, like neural networks, automatically learn features from raw data,
eliminating the need for manual feature engineering. They require large datasets
and significant computational resources but have achieved remarkable success
in various domains, revolutionizing tasks like computer vision and sequential
data processing.
Deep learning has achieved remarkable success in various domains,
including computer vision, where Convolutional Neural Networks (CNNs)
have revolutionized tasks such as object detection and image classification.
Recurrent Neural Networks (RNNs) and their variants, such as Long Short-
Term Memory (LSTM) networks, are widely used for sequential data
processing tasks like speech recognition and language translation. Deep
learning fundamentally transforms how computers perceive, understand, and
interact with the world. Its architecture, inspired by the human brain's neural
networks, consists of layers of interconnected nodes, each processing and
extracting features from data at increasing levels of abstraction. This
hierarchical representation allows deep learning models to learn complex
patterns and relationships directly from raw data, without the need for
handcrafted features or explicit programming. The widespread adoption of deep
learning has led to groundbreaking advancements in numerous fields, including
healthcare, where it aids in disease diagnosis and personalized treatment
recommendations, and in autonomous vehicles, where it enables vehicles to
perceive and navigate complex environments safely.
3
CHAPTER 2
LITERATURE SURVEY
Merits: CNN algorithm is applied to a skin cancer project for detection and
classification purpose and deep learning capabilities to analyze medical images.
4
[2] TITLE: Skin cancer detection using combined decision of deep
learners (2022).
Author: Azhar Imran, Arslan Nasir.
Merits: VGG, Caps-Net, and ResNet, applied in skin cancer prediction with
CNNs, employ diverse architectures for extract features from the leison image.
5
[3] TITLE: Skin cancer classification using image processing and
machine learning (2021).
One of the most rapidly spreading cancers among various other types of
cancers known to humans is skin cancer. Melanoma is the worst and the most
dangerous type of skin cancer that appears usually on the skin surface and then
extends deeper into the layers of skin. However, if diagnosed at an early stage; the
survival rate of Melanoma patients is 96% with simple and economical treatments.
The conventional method of diagnosing Melanoma involves expert dermatologists,
equipment, and Biopsies. In this paper, a method for skin lesion classification and
segmentation as benign or malignant is proposed using image processing and
machine learning. A novel method of contrast stretching of dermoscopic images
based on the methods of mean values and standard deviation of pixels is proposed.
Then the thresholding algorithm is applied for image segmentation. After the
segmentation, features including Gray Level Co-occurrence Matrix (GLCM)
features for texture identification, the Histogram of Oriented Gradients (HOG)
object, and color identification features are extracted from the segmented images.
Principal Component Analysis (PCA) reduction of HOG features is performed for
dimensionality reduction. Synthetic Minority Oversampling Technique (SMOTE)
sampling is performed to deal with the class imbalance problem. The feature vector
is then standardized and scaled. A novel approach of feature selection based on the
wrapper method is proposed before classification. Classifiers including Quadratic
Discriminant, SVM (Medium Gaussian), and Random Forest are used for
classification. Maximum accuracy is achieved using the Random Forest classifier.
6
[4] TITLE: Skin Cancer Detection using Machine Learning Techniques
(2020).
Author: Vidya M, Dr. Maya V Karki.
7
[5] TITLE: Skin Cancer Detection: Applying a deep learning based
model driven architecture in the cloud for classifying dermal cell images
(2020).
Author: Mohammad Ali Kadampur, Sulaiman Al Riyaee.
8
[6] TITLE: Skin Cancer Classification using Deep Learning and
Transfer Learning (2019).
Author: Khalid M. Hosny, Mohamed A. Kassem.
Skin cancer specially melanoma is one of most deadly diseases. In the color
images of skin there is a high similarity between different skin lesion like
melanoma and nevus, which increase the difficulty of the detection and diagnosis.
A reliable automated system for skin lesion classification is essential for early
detection to save effort, time and human life. In this paper, an automated skin lesion
classification method is proposed. In this method, a pre-trained deep learning
network and transfer learning are utilized. In addition to fine-tuning and data
augmentation, the transfer learning is applied to AlexNet by replacing the last layer
by a softmax to classify three different lesions (melanoma, common nevus and
atypical nevus). The proposed model is trained and tested using the ph2 dataset.
The well-known quantative measures, accuracy, sensitivity, specificity, and
precision are used in evaluating the performance of the proposed method where the
obtained values of these measures are 98.61%, 98.33%, 98.93%, and 97.73%,
respectively. The performance of the proposed method is compared with the
existing methods where the classification rate of the proposed method
outperformed the performance of the existing methods.
Techniques: PH2 dataset is used.
Merits: The data augmentation, the transfer learning is applied to AlexNet by
replacing the lastlayer by a softmax to classify three different lesions.
9
CHAPTER 3
SYSTEM ANALYSIS
10
3.1.1 Disadvantages:
⚫ Lower accuracy can result in misdiagnosis or missed detection of critical
conditions, leading to potential health risks for patients.
⚫ If the dataset used for training the deep learning models lacks diversity in
lesion types, sizes, and textures, the models may struggle to generalize well
to real-world scenarios.
⚫ The dataset comprising only images of individuals with white skin tone
poses a significant limitation. Skin conditions can manifest differently based
on skin tone, ethnicity, and genetic predispositions.
⚫ Due to the aforementioned limitations, the existing system may suffer from
generalization issues. Generalization refers to the ability of a deep learning
model to perform accurately on unseen data.
Deep learning models for early detection and classification of skin cancer
address critical healthcare challenges by leveraging advanced AI techniques.
These models aim to accurately classify skin lesions, particularly melanoma,
from dermoscopic images, enhancing early diagnosis and improving patient
outcomes. The multimodal data sources, including clinical metadata and patient
history, these models provide a comprehensive understanding of skin lesions,
aiding in timely intervention and treatment planning. Additionally, deep
learning frameworks enable real-time segmentation and classification of skin
lesions. Federated learning approaches ensure privacy-preserving collaboration
among healthcare institutions, enabling collective knowledge sharing without
compromising patient confidentiality. Overall, deep learning models represent
a promising avenue for revolutionizing skin cancer diagnosis and management,
contributing to improved patient care and outcomes.
11
3.3 PROPOSED SYSTEM:
The proposed system for early detection and classification of skin cancer
is a comprehensive approach integrating cutting-edge deep learning techniques
such as Convolutional Neural Networks (CNNs), Support Vector Machines
(SVMs), and decision trees. This multifaceted approach is designed to maximize
accuracy and reliability in identifying potential cancerous lesions. A pivotal
aspect of the system involves augmenting the dataset size substantially, a
strategy proven to enhance model performance by providing a more
comprehensive and representative sample of skin conditions.
To further refine the dataset and improve accuracy, sophisticated feature
selection methods are employed to eliminate redundant or irrelevant attributes.
By prioritizing relevant features, the system optimizes the learning process,
resulting in more precise and reliable predictions. Through the synergistic
application of advanced algorithms and meticulous dataset optimization
techniques, the proposed system represents a significant advancement in the
early detection and classification of skin cancer, promising to revolutionize
diagnosis and treatment in dermatology. This prioritization of relevant features
optimizes the learning process, resulting in more precise and reliable
predictions. By synergistically applying advanced algorithms and meticulous
dataset optimization techniques, the proposed system represents a significant
advancement in the early detection and classification of skin cancer, promising
to revolutionize diagnosis and treatment in dermatology.
12
3.3.1 Advantages:
⚫ Deep learning algorithms have the ability to learn intricate patterns and
features within skin images, leading to more precise identification of
potential abnormalities.
⚫ The inclusion of a diverse range of lesions in the dataset is crucial for
effective skin cancer detection.
⚫ Skin cancer can affect individuals of all ethnicities and skin tones.
Therefore, it's essential to have a dataset that represents the diversity of skin
tones encountered in the population.
⚫ Deep learning models can achieve higher sensitivity and specificity in
detecting skin lesions compared to traditional methods.
⚫ Deep learning-based systems can automate the process of lesion detection
and classification, reducing the time and effort required for manual
evaluation by dermatologists.
⚫ Once trained, deep learning models can be deployed across various
healthcare facilities, regardless of their geographical location or resource
availability.
⚫ Deep learning models have the capability to continuously learn and improve
over time.
13
CHAPTER 4
SYSTEM DESCRIPTION
➢ RAM : 4GB
14
Programming Language: Python
Python is an interpreted high-level programming language for general- purpose
programming. Created by Guido van Rossum and first released in 1991, Python has a
design philosophy that emphasizes code readability, notably using significant
whitespace. It provides constructs that enable clear programming on both small and
large scales. In July 2018, Van Rossum stepped down as the leader in the language
community. Python features a dynamic type system and automatic memory
management. It supports multiple programming paradigms, including object- oriented,
imperative, functional, and procedural, and has a large and comprehensive standard
library. Python interpreters are available for many operating systems. Python, the
reference implementation of Python, is open- source software and has a community-
based development model, as do nearly all of Python's other implementations. Python
is managed by the non- profit Python Software Foundation.
Rather than having all of its functionality builtinto its core, Python was designed to be
highly extensible. This compact modularity has made it particularly popular as a
means of adding programmable interfaces to existing applications. Van Rossum's
vision of a small core language with a large standard library and easily extensible
interpreter stemmed from his frustrations with ABC, which espoused the opposite
approach. The Python interpreter and the extensive standard library are available in
source or binary form without charge forall major platforms and can be freely
distributed. Often, programmers fall in love with Python because of the increased
productivity it provides. Since there is no compilation step, the edit-test-debug cycle
is incredibly fast. Debugging Python programs is easy: a bug or bad input will never
cause a segmentation fault. Instead,when the interpreter discovers an error, it raises an
exception. When the program doesn't catch the exception, the interpreter prints a stack
trace. A source-level debugger allows inspection of local and global variables,
evaluation of arbitrary expressions.
15
CHAPTER 5
SYSTEM DESIGN
16
This project relies heavily on the quality and diversity of the image
dataset. To this end, we procure a vast array of skin lesion images sourced from
the prestigious International Skin Imaging Collaboration (ISIC) dataset. This
rich dataset encompasses a spectrum of skin conditions, ensuring our models
are trained and tested on a comprehensive range of benign and malignant
lesions, thus bolstering the robustness of our system. The cornerstone of our
classification approach lies in the deployment of Convolutional Neural
Networks (CNNs).
Renowned for their prowess in extracting hierarchical features directly
from raw image data, CNNs are perfectly suited for discerning intricate patterns
inherent in skin lesions. Through extensive training on the ISIC dataset, our
CNN model hones its ability to differentiate between various types of skin
lesions with remarkable precision and reliability. Complementing the
classification phase is our utilization of Support Vector Machines (SVMs) for
feature extraction. By focusing on key attributes such as color, structure,
boundary, and area, SVMs facilitate the extraction of salient features crucial for
distinguishing between benign and malignant lesions.
Their efficacy in high-dimensional feature spaces ensures that our system
can capture nuanced characteristics inherent in the skin lesion images. At the
crux of our diagnostic pipeline lies the implementation of decision tree
algorithms. These algorithms excel in offering transparent and interpretable
decision rules, making them particularly well-suited for medical diagnosis tasks.
By analyzing the extracted features, our decision tree model is adept at
predicting whether a given skin lesion is benign or malignant, thus empowering
healthcare professionals with actionable insights for effective patient
management. To enhance accessibility and usability, our system is seamlessly
integrated with web technologies.
17
5.2 DATA FLOW DIAGRAM:
A data flow diagram for deep learning models aimed at early detection
and classification of skin cancer would depict the flow of information
throughout the system. At its core, the diagram would showcase the journey of
data, starting with the input of various skin images, including those with
suspected lesions or abnormalities. These images would then undergo
preprocessing steps such as resizing, normalization, and possibly augmentation
to enhance model performance and generalization. Subsequently, the
preprocessed images would be fed into the deep learning model, which could
consist of convolutional neural networks (CNNs) or other architectures
optimized for image analysis tasks.
The model would then analyze the input images, extracting relevant
features and patterns indicative of different types of skin cancer, such as
melanoma, basal cell carcinoma, or squamous cell carcinoma. The
classification results would then be outputted, often in the form of probabilities
assigned to each class, indicating the likelihood of the presence of specific types
of cancer. These results could further be visualized, interpreted, and used to
guide clinical decision-making processes, such as determining the necessity for
further diagnostic tests or treatments. Additionally, feedback loops may exist
within the system to continuously improve model performance through
mechanisms like retraining on new data or fine-tuning based on user feedback
and ground truth annotations. Overall, the data flow diagram illustrates the
intricate pipeline through which deep learning models leverage input data to
facilitate early detection and classification of skin cancer, potentially
contributing to improved patient outcomes and healthcare delivery.
18
LEVEL 0:
At the highest level, a Level 0 data flow diagram for the process of
collecting, augmenting, and preprocessing image data for deep learning models
focused on skin cancer detection would illustrate the key stages of this data
pipeline.
19
LEVEL 1:
At the level 1 data flow diagram level, the process begins with "Image
Acquisition," where various skin images, including those with suspected lesions,
are gathered.
These images serve as the primary input data for the system. Next, in
"Image Preprocessing," the acquired images undergo essential preprocessing
steps such as resizing, normalization, and potentially augmentation to ensure
consistency and enhance the model's ability to extract meaningful features.
Following preprocessing, the images flow into "Image Segmentation," a crucial
step where the images are analyzed to delineate regions of interest, such as
potential lesions or abnormalities, from the surrounding healthy tissue. This
segmentation process helps focus the model's attention on relevant areas,
improving diagnostic accuracy.
20
CHAPTER 6
SYSTEM IMPLEMENTATION
6.1 MODULES
⚫ Train Module
⚫ Segmentation Module
⚫ Backend Module
In this project, modules serve as distinct units of both software and hardware,
each designed to fulfill specific functions within the system. One key characteristic of
these modular components is portability, meaning they are constructed in a manner that
enables their seamless integration into a variety of systems without requiring extensive
modification. This portability facilitates versatility in deployment, allowing the
modules to be utilized across different platforms and environments. Another essential
attribute of these modules is interoperability, which enables them to effectively interact
and function with components from other systems. The identified modules include the
Test Module, responsible for evaluating the performance and accuracy of the system;
the Train Module, tasked with training the system using available data; the
Segmentation Module, which focuses on segmenting and isolating relevant features
within input data; and the Backend Module, which provides the underlying framework
and support for the system's functionalities, scalability, thereby enhancing the overall
robustness and flexibility of the system.
21
6.2 MODULES DESCRIPTION
You test cases with positive inputs,inputs with zero, negative inputs, and
positive and negative inputs. If the output of our function/method being tested would
be equal to the outputs defined in the unit test for all the input cases, your unit
would pass the test otherwise it would fail.
22
Pre-processing:
pre-processing is crucial to ensure the quality and relevance of the
input data. Initially, the dataset would undergo thorough cleaning to remove
any irrelevant or corrupted images. Following this, standardization techniques
such as normalization and resizing would be applied to ensure consistency
across images. Augmentation techniques like rotation, flipping, and adjusting
brightness can help in increasing the diversity of the dataset, which aids in
robust model training. Additionally, data augmentation can help mitigate
issues related to class imbalance, common in medical datasets.
Segmentation:
Segmentation plays a pivotal role in deep learning models. By
accurately delineating the boundaries of lesions or anomalies within skin
images, segmentation enables precise analysis and classification. Leveraging
techniques such as semantic segmentation or instance segmentation, these
models can effectively identify suspicious regions for further examination.
Feature extraction:
Feature extraction plays a pivotal role in capturing relevant
information from medical images. Initially, a dataset comprising various types
of skin lesions, including benign and malignant ones, is collected.
Preprocessing techniques such as normalization and augmentation are applied
to enhance the quality and diversity of the data.
Classification:
Fine-tune a deep learning architecture such as Convolutional Neural
Networks (CNNs), possibly leveraging pre-trained models like VGG, ResNet,
or DenseNet. The model would be trained using a portion of the dataset and
validated on another to optimize hyperparameters and prevent overfitting.
23
6.2.2 Train Module
The module encapsulates the knowledge and capabilities gained from
training various machine learning algorithms, including CNNs, SVMs, and
Decision Trees, to detect and classify skin cancer from dermatoscopic images.
During the training phase, the module learns to recognize patterns and features
indicative of different types of skin lesions, such as melanoma, nevi, and benign
lesions. Through iterative optimization and adjustment of model parameters,
the module becomes increasingly proficient at accurately identifying these
lesions. Once trained, the module acts as an intelligent system capable of
analyzing new dermatoscopic images and providing predictions regarding the
presence and type of skin cancer.
In essence, the trained module represents the culmination of the project's
research and development efforts, serving as a valuable tool for early detection
and classification of skin cancer. Its successful deployment promises to
enhance diagnostic accuracy, facilitate early intervention, and ultimately
improve patient outcomes in the fight against this prevalent and potentially life-
threatening disease.
The ISIC dataset, which contains a large collection of dermatoscopic
images, serves as the primary source of data for training and testing the model.
Deep learning algorithms, specifically Convolutional Neural Networks
(CNNs), play a pivotal role in this project. CNNs are adept at automatically
learning relevant features from images, making them well-suited for tasks like
image classification. By training a CNN on the ISIC dataset, the model can
learn to differentiate between benign and malignant skin lesions based on their
visual characteristics.
24
6.2.3 Segmentation Module
The segmentation module serves as a critical component by precisely
outlining skin lesions in images from the ISIC dataset. This dataset, rich with
annotated dermatoscopic images, provides a robust foundation for training deep
learning models. Among the algorithms utilized, convolutional neural networks
(CNNs) take center stage for their prowess in learning intricate features from
images, enabling accurate segmentation of lesions. Complementing CNNs,
support vector machines (SVMs) and decision trees contribute their strengths
in handling high-dimensional data and defining decision boundaries for
classification tasks. By integrating these algorithms with the segmentation
module, the project endeavors to enhance the precision and efficiency of skin
cancer diagnosis, potentially leading to earlier detection and improved patient
care.
25
6.2.4 Backend Module
The backend module for the early detection and classification of skin
cancer project using the ISIC dataset, a comprehensive approach is adopted.
Firstly, Convolutional Neural Networks (CNNs) are employed due to their
prowess in learning intricate patterns and features from skin images. These
CNNs will be pivotal in extracting relevant features that distinguish between
benign and malignant lesions, thus aiding in accurate classification.
Additionally, Support Vector Machines (SVMs) are utilized as they offer a
robust classification technique, particularly useful for binary classification
tasks like cancer detection.
Moreover, Decision Trees are incorporated for their interpretability,
enabling the understanding of the decision-making process behind the
classification. The backend module encompasses data preprocessing, model
training, and evaluation processes, ensuring that the system efficiently and
accurately identifies potential skin cancer cases at an early stage, thereby
enhancing the chances of successful treatment and patient outcomes.
Convolutional Neural Networks (CNNs) will be essential for their ability to
learn intricate patterns from skin images, aiding in accurate classification.
Support Vector Machines (SVMs) will complement CNNs, providing a robust
classification method.
Decision Trees can be employed for their interpretability, potentially
aiding in understanding the features contributing to the classification. The
backend will handle data preprocessing, model training, and evaluation,
ensuring the efficient and accurate detection and classification of skin cancer.
26
ALGORITHM
Convolutional Neural Network (CNN):
Convolutional neural networks are also able to drastically reduce
computation time by taking advantage of GPU for computation, which many
networks fail to utilize. Deep learning algorithms run data through several
“layers” of neural network algorithms, each of which passes a simplified
representation of the data to the next layer. Most machine learning algorithms
work well on datasets that have up to a few hundred features, or columns.
Decision Tree:
28
6.3 IMPLEMENTATION
The project for early detection and classification of skin cancer through
deep learning models incorporates several key implementation details to
achieve its objectives. Leveraging the ISIC dataset, annotated with
dermatoscopic images, the project employs convolutional neural networks
(CNNs) for precise lesion segmentation, enabling accurate delineation of skin
abnormalities. These segmented regions are then fed into classification
algorithms such as support vector machines (SVMs) and decision trees, which
handle high-dimensional data and define decision boundaries for effective
classification. The CNN-based segmentation module is trained using annotated
data, while the classification models are fine-tuned on a subset of the dataset to
optimize performance. Additionally, techniques such as data augmentation and
transfer learning are employed to enhance model generalization and robustness.
29
CHAPTER 7
SYSTEM TESTING
7.1 TESTING OBJECTIVES:
The primary objective of the deep learning models for early detection
and classification of skin cancer, the testing objectives are multifaceted. The
models need to be rigorously evaluated for their ability to accurately detect
potential indicators of skin cancer at its nascent stages, thereby emphasizing
sensitivity. The specificity of the models is paramount to ensure that benign
lesions are not falsely identified as malignant, minimizing unnecessary patient
anxiety and medical interventions. Moreover, the robustness of the models
across diverse demographics, skin types, and lesion variations should be
thoroughly assessed to ascertain their generalizability and real-world
applicability. By addressing these testing objectives comprehensively, the
efficacy and reliability of deep learning models for early skin cancer detection
can be substantiated, potentially revolutionizing diagnostic practices and
improving patient outcomes.
7.2 TYPES OF TESTING
System Testing
System testing in a deep learning models for early detection and
classification of skin cancer capabilities is crucial for ensuring its functionality,
usability, reliability. This testing process encompasses several key areas. It
contains several testing approaches within this system testing.
Unit Testing:
Image detection capabilities must be rigorously tested to identify
obstacles and relevant items accurately by comparing with dataset. Unit testing
involves scrutinizing individual components of the deep learning model, such
as specific layers or modules, to verify their functionality and correctness.
30
Functional Testing:
Functional testing assesses the system's performance as a whole,
examining its ability to accurately identify and classify different types of skin
lesions across diverse datasets and scenarios. testing methodologies are
essential to ensure the system's accuracy and reliability.
31
7.3 TEST CASE
Early detection and classification of skin cancer using deep learning
models, The test cases that thoroughly evaluate the performance and robustness
of your model.
Test Case 1:
Test Case: Input an image of a benign mole, Feed the image into the deep learning
model.
Expected Outcome: The model should classify the mole as benign with high
confidence.
Test Case 2:
Test Case: Input the image into the deep learning model.
Expected Outcome: The model should classify the melanoma as malignant with
high confidence.
Test Case 3:
Test Case: Input the image into the deep learning model.
Expected Outcome: The model should provide a warning or indicate low confidence
due to the poor quality of the image.
Test Case 4:
Test Case: Feed the image into the deep learning model.
Expected Outcome: The model should correctly classify the skin condition as
non-cancerous with high confidence.
32
CHAPTER 8
RESULT AND DISCUSSION
8.1 PERFORMANCE ANALYSIS
The primary objective of the deep learning models for early detection
and classification of skin cancer, the testing objectives are multifaceted. The
models need to be rigorously evaluated for their ability to accurately detect
potential indicators of skin cancer at its nascent stages, thereby emphasizing
sensitivity. The specificity of the models is paramount to ensure that benign
lesions are not falsely identified as malignant, minimizing unnecessary patient
anxiety and medical interventions. Beyond quantitative metrics, qualitative
assessments including clinical relevance, ease of integration into existing
healthcare workflows, and potential for real-time diagnosis also play a
significant role. A comprehensive performance analysis not only validates the
utility of these models but also guides further refinement and deployment
strategies, ultimately advancing the early detection and management of skin
cancer.
Accuracy
The skin cancer detection, the utilization of deep learning models offers
not only heightened accuracy but also an array of performance metrics crucial
for robust diagnostic systems. Precision, a metric measuring the proportion of
true positive predictions among all positive predictions, ensures that identified
cases are reliably classified as cancerous. The F1 score, a harmonic mean of
precision and recall, provides a balanced assessment of a model's effectiveness
in both minimizing false positives and false negatives. Recall, also known as
sensitivity, gauges the model's ability to detect all positive instances, thus
crucial for capturing all potentially cancerous lesions. Additionally, accuracy
serves as a fundamental metric, representing the
overall correctness of the model's predictions across all classes. By optimizing
33
these metrics, deep learning models not only enhance diagnostic accuracy but
also instill confidence in their ability to identify and classify skin lesions,
ultimately facilitating early intervention and improving patient outcomes.
34
Po is the observed agreement, which is the proportion of instances where
the raters (or in this case, the model and the ground truth) agree. Pe is the
expected agreement, which is the proportion of instances where agreement is
expected to occur by chance. To calculate Po , The number of instances where
the model and ground truth agree by the total number of instances. To calculate
Pe, compute the probability of random agreement for each class and then sum
them.
8.2 TRAINING ANALYSIS
Figure (a) depicts the training accuracy and validation accuracy plotted
against the number of epochs during the training of a deep learning model for
skin cancer detection. Both training and validation accuracy increase as the
number of epochs rises. This trend suggests that the model is learning from the
training data and improving its ability to correctly classify skin lesions over
time. The epochs value considered determines the number of times the entire
dataset is passed forward and backward through the neural network during
training. With each epoch, the model updates its internal parameters (weights
and biases) based on the errors calculated from the training data, gradually
35
improving its performance.
In Figure (b), the loss graph for both training and validation data is shown
as the number of epochs increases. Loss represents the discrepancy between the
predicted outputs of the model and the actual labels in the training and
validation datasets. As the value of an epoch rises, the loss decreases until it
becomes almost nonexistent. This indicates that the model is effectively
minimizing its errors and becoming increasingly accurate in its predictions. The
decreasing loss signifies that the model is converging towards an optimal
solution, where the difference between predicted and actual values is
minimized.
Overall, both figures demonstrate the progressive improvement of the
deep learning model over epochs, with increasing accuracy and decreasing loss
on both training and validation datasets. This indicates successful learning and
convergence of the model, ultimately leading to better performance in detecting
and classifying skin cancer lesions.
36
CHAPTER 9
APPENDICES
9.1 SOURCE CODE
Main.py
from flask import Flask, render_template, request, jsonify, send_file,
import pandas as pd
from PIL import Image, ImageDraw
import random
import os
import ntpath
import base64
import pickle
from io import BytesIO
from torch import Tensor, load
import numpy as np
from SkinCancer.Model import SkinCancerModel
app = Flask( name )
def serve_pil_image(pil_img):
img_io = BytesIO()
pil_img.save(img_io, format='JPEG', quality=100)
img_io.seek(0)
img_i = base64.b64encode(img_io.getvalue()).decode()
return {'image': img_i}
@app.route('/diagnosis/skin_cancer', methods=['GET', 'POST'])
def skin_cancer():
def get_prediction(pil_img, age, gender):
pil_img = pil_img.resize([128, 128])
age_t = Tensor([age]).reshape(1, 1)
37
gender_t = Tensor([gender]).reshape(1, 1)
img_t = Tensor(np.array(pil_img)).reshape(1, 3, 128, 128)
model = SkinCancerModel()
model.load_state_dict(load('SkinCancer/model_skin_cancer_epoch40.pt'))
model.eval()
pred = np.round(model.forward(img_t, gender_t,
age_t).detach().numpy())
return int(pred)
if request.method == 'GET':
return render_template('skin-cancer.html')
else:
if 'use_random' in request.form.keys():
if int(request.form.get('use_random')) == 1:
random_path =
os.path.join('SkinCancer/RandomData/images',
random.choice(os.listdir('SkinCancer/RandomData/images')))
file_name =
ntpath.basename(ntpath.splitext(random_path)[0])
metadata =
pd.read_csv('SkinCancer/RandomData/meta_data.csv')
row = metadata.loc[(metadata['image_id'] ==
file_name)]
gender = row['sex'].item()
if gender == 'male':
gender = 1
elif gender == 'female':
gender = 0
38
img = Image.open(random_path).convert('RGB') res =
serve_pil_image(img.resize([400, 400])) res['prediction'] =
get_prediction(img, age, gender) return jsonify(res)
print('File: {}'.format(request.files.get('skin-cancer-
Train_model.py
from src.SkinCancer.Model import SkinCancerModel
40
from src.SkinCancer.Dataloader import TrainDataset
from torch import save
import torch.nn as nn
import pandas as pd
from torch.optim import Adam
from torch.utils.data import DataLoader
model = SkinCancerModel()
optimizer = Adam(model.parameters())
criterion = nn.BCELoss()
train_dataset = TrainDataset()
ground_truth = pd.read_csv('/home/aftaab/MylanDatasets/Skin
Cancer/ground_truth.csv')
train_loader = DataLoader(train_dataset, batch_size=128, shuffle=True)
def train(epoch):
for step, data in enumerate(train_loader):
train_x, train_y, sm, am = data
sex_t = sm.float()
age_t = am.float()
train_y = train_y.float().view(-1, 1)
optimizer.zero_grad()
y_pred = model.forward(train_x, sex_t, age_t)
loss = criterion(y_pred, train_y)
loss.backward()
optimizer.step()
print('Epoch {}, batch={}, loss={}'.format(epoch, step,
loss.item()))
for i in range(1, 41):
train(i)
41
if i % 5 == 0:
save(model.state_dict(),
'model_skin_cancer_epoch{}.pt'.format(i))
Dataloader.py
from torch.utils.data import Dataset
import pandas as pd
from sklearn.model_selection import train_test_split
import numpy as np
from PIL import Image
import ntpath
from torch import Tensor
from glob import glob
all_files = glob('/home/aftaab/MylanDatasets/Skin Cancer/*.jpg')
ground_truth = pd.read_csv('/home/aftaab/MylanDatasets/Skin
Cancer/ground_truth.csv')
meta_data = pd.read_csv('/home/aftaab/MylanDatasets/Skin
Cancer/ISIC-2017_Training_Data_metadata.csv')
train, test = train_test_split(all_files, test_size=0.15)
melanoma_dict = {}
n_samples = sum(ground_truth['melanoma'])
n_negatives = 0
n_positives = 0
for (index, row), (index1, row1) in zip(ground_truth.iterrows(),
meta_data.iterrows()):
if n_negatives<=n_samples and row['melanoma']==0:
melanoma_dict[row['image_id']] = {'target': row['melanoma'],
'gender': row1['sex'], 'age': row1['age_approximate']}
n_negatives+=1
42
elif n_positives<=n_samples and row['melanoma']==1:
melanoma_dict[row['image_id']] = {'target': row['melanoma'],
'gender': row1['sex'], 'age': row1['age_approximate']}
n_positives+=1
else:
all_files_temp = all_files
for file in all_files:
file_name = ntpath.basename(ntpath.splitext(file)[0])
if file_name == row['image_id']:
all_files_temp.remove(file)
break
all_files = all_files_temp
print('Undersampling to {} positive, {} negative
samples.'.format(n_negatives, n_positives))
train, test = train_test_split(all_files, test_size=0.15)
class TrainDataset(Dataset):
def init (self):
super(). init ()
def getitem (self, index):
file_path = train[index]
img =
np.array(Image.open(file_path).convert('RGB').resize([128, 128]))
img = Tensor(img).view(3, 128, 128)
file_name = ntpath.basename(ntpath.splitext(train[index])[0])
y=0
age = -1
sex = -1
43
if melanoma_dict.get(file_name) is not None:
y = melanoma_dict.get(file_name)['target']
g = melanoma_dict.get(file_name)['gender']
if g == 'female':
g=0
elif g == 'male':
g=1
else:
g = -1
sex = g
age = melanoma_dict.get(file_name)['age']
if type(age) == str:
age = -80
return [img, y, sex, age]
def len (self):
return len(train)
class TestDataset(Dataset):
def init (self):
super(). init ()
47
9.2 SCREENSHOTS
Developed Web Page:
The web page offers a powerful tool in the fight against skin cancer,
utilizing cutting-edge deep learning models for early detection and accurate
classification. With a user-friendly interface, individuals can upload images of
suspicious moles or lesions, allowing our advanced algorithms to swiftly
analyze and provide instant feedback. Our system not only detects potential
signs of skin cancer but also categorizes them for further medical evaluation,
empowering users to take proactive steps towards early intervention and
treatment. Through the fusion of technology and healthcare, we aim to enhance
early detection rates, ultimately saving lives and promoting healthier.
48
Interior Page
Using this page,the interior webpage dedicated to deep learning models for
the early detection and classification of skin cancer. Here, users can explore
cutting-edge technology aimed at revolutionizing the diagnosis process. Through
advanced algorithms and machine learning techniques, our models analyze
various skin lesions, providing accurate assessments to aid in early detection and
classification. Whether you're a healthcare professional, researcher, or individual
concerned about skin health, this page offers insights into the innovative tools
driving progress in skin cancer diagnosis. Explore our resources to learn more
about how deep learning is shaping the future of dermatology and improving
patient outcomes.
49
Image Upload Page
50
Positive Result Page
51
Negative Result Page
52
CHAPTER 10
CONCLUSION AND SCOPE FOR FUTURE WORK
10.1 CONCLUSION
In conclusion, the utilization of deep learning models such as
Convolutional Neural Networks (CNN), Support Vector Machines (SVM), and
Decision Trees has shown promising results in the early detection and
classification of skin cancer. These models leverage complex patterns and
features within medical images to accurately diagnose different types of skin
lesions. While CNNs excel in feature extraction and hierarchical representation
learning, SVMs and decision trees offer interpretability and efficiency in
classification tasks. However, further research and validation are necessary to
optimize and deploy these models effectively in clinical settings.
53
REFERENCES
1. Aarushi Shah, Manan Shah, Aum Pandya, Rajat Sushra, Ratnam Sushra,
Manya Mehta, Keyur Patel, Kaushal Patel, (2023). "A comprehensive
study on skin cancer detection using artificial neural network (ANN) and
convolutional neural network (CNN)" Vol.9, pp.2588-9141 2023.
2. Aliasgar Pardawala, Sakshi Jagtap, Tayyaba Pinjari, Ruttik Trymbake,
Mrs. Deepika Falak, (2023). "Skin Cancer Detection Using CNN", Vol.9,
pp.2349-5162.
3. Arslan Javaid, Muhammad Sadiq, Faraz Akram, (2021). "Skin Cancer
Classification Using Image Processing",IEEE Explore access, Vol.10,
pp.9393-1981.
4. Atikur Rahman, Muhammad Sheikh Sadi (2022). "IoT Enabled
Automated Object Recognition for the Visually Impaired", Vol.1,
pp.100-128.
5. GS Gopika Krishnan, M. Lekha, A. Meghana Shravani, G. Milirna,
(2023). "Skin Cancer Detection Using Machine Learning", Vol.7,
pp.2582-5208.
6. Justin Seby, Sysvine Technologies, (2021). " Skin Cancer Detection
Using Convolutional Neural Network", Vol.9, pp.2320-2882.
7. Khalid M. Hosny, Mohamed A. Kassem, and Mohamed M. Foaud,
(2018), "Skin Cancer Classification using Deep Learning and Transfer
Learning", IEEE access, Vol.1, pp.978-1-5386-8154-1.
54
8. Manjunath H R, (2023). "Skin Cancer Detection Using Machine
Learning", Vol.4, pp.4573-3410
9. Maryam Naqvi, Syed Qasim Gilani, Tehreem Syed Oge Marques and
Hee-Cheol Kim. (2023), "Skin Cancer Detection Using Deep Learning",
10. Mohammad Ali Kadampur, Sulaiman Al Riyaee, (2020) "Skin cancer
detection: Applying a deep learning based model driven architecture in
the cloud for classifying dermal cell images", Vol.5, pp.2352-9148
11. Neema M, Arya S Nair, Annette Joy, Amal Pradeep Menon, (2020).
"Skin Lesion/Cancer Detection Using Deep Learning", Vol.15, pp.0973-
4562.
12. Noortaz Rezaoana, Mohammad Shahadat Hossain, Karl Andersson
(2020) "Detection and Classification of Skin Cancer by Using a Parallel
CNN Model", IEEE access, Vol.3, pp. 978-0-7381-3144-3.
13. Pamela Hermosilla, Ricardo Soto, Emanuel Vega, Cristian Suazo and
Jefte Ponce, (2023). "Skin Cancer Detection and Classification Using
55
PUBLICATION
56