Skin - Cancer - Report Final
Skin - Cancer - Report Final
BACHELOR OF ENGINEERING
In
ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING
By
The satisfaction and the successful completion of this mini project would be incomplete
without the mention of the people who made it possible, and whose constant guidance
and encouragement crowned our efforts with success.
This Mini project is made under the guidance of Dr Maryjo M George, Assistant
Professor in the Department of Artificial Intelligence and Machine Learning. We would
like to express our sincere gratitude to our guide for all the helping hand and guidance in
this project
We also thank our management who helped us directly or indirectly in the completion of
this mini-project.
Our special thanks to faculty members and others for their constant help and support.
Above all, we extend our sincere gratitude to our parents and friends for their constant
encouragement with moral support.
Dhruva Kumar Shetty
(4MT2AI009)
Pramith A Naiga
(4MT20AI027)
ABSTRACT
Skin cancer is a prevalent and potentially life-threatening disease that, if detected early,
can significantly improve patient outcomes. In this project, we propose a skin cancer
detection system employing deep learning techniques. Leveraging the power of transfer
learning, we utilize the ResNet50 architecture, a pre-trained convolutional neural
network (CNN), to automatically learn intricate features from skin lesion images. The
dataset comprises a diverse collection of benign and malignant skin lesions.
The workflow involves data loading, preprocessing, and augmentation, followed by the
construction of a custom classification model on top of the ResNet50 base. The model
is trained on a subset of the dataset, with a focus on optimizing classification accuracy.
Additionally, we employ early stopping to mitigate overfitting during the training
process.
The evaluation phase involves assessing the model's performance on a separate test set,
providing key metrics such as accuracy, precision, recall, and F1-score. Furthermore,
we visualize the training and validation curves to gain insights into the model's
convergence.
Our project not only showcases the potential of deep learning in skin cancer detection
but also serves as a foundation for further research and development in the domain of
medical image analysis.
TABLE OF CONTENTS
1 INTRODUCTION 1
3 METHODOLOGY 4-11
3.1 DATASETS
3.2 DATA PREPROCESSING AND FEATURE EXTRACTION
3.3 ALGORITHMS IN PICTURE
5 TESTING 14-16
5.1 TEST PROCESS
5.2 TEST CASES
7 CONCLUSION 20
8 REFERENCES 21
SKIN CANCER DETECTION
Chapter 1
INTRODUCTION
Skin cancer, among the most prevalent forms of cancer globally, poses a substantial
public health challenge. Timely detection and accurate diagnosis play a pivotal role in
enhancing patient outcomes and reducing the morbidity associated with this disease.
Traditional methods of skin cancer diagnosis heavily rely on visual inspection by
dermatologists, a process that can be time-consuming and subjective. In recent years,
advances in deep learning, particularly convolutional neural networks (CNNs), have
demonstrated remarkable capabilities in image classification tasks, including medical
image analysis. This project endeavors to harness the potential of deep learning to
create an automated system for skin cancer detection, facilitating early diagnosis and
intervention. The primary objective of this project is to develop a robust and accurate
model capable of distinguishing between benign and malignant skin lesions. To
achieve this, we leverage transfer learning, utilizing the ResNet50 architecture as a
pre-trained feature extractor. This approach allows the model to benefit from the
knowledge gained through training on a diverse set of images, enabling it to recognize
intricate patterns and features associated with skin cancer.
The manual diagnosis of skin lesions is time-consuming and subjective, often leading
to delays in treatment. Leveraging the power of deep learning, our project aims to
develop an efficient and accurate model capable of automatically discerning between
benign and malignant skin lesions. By addressing these challenges, we seek to enhance
the speed and accuracy of skin cancer diagnosis, ultimately improving patient
outcomes.
This project focuses on utilizing transfer learning with the ResNet50 architecture,
incorporating data loading, preprocessing, and model training. Through this endeavor,
we aspire to contribute to the field of dermatology by providing a reliable tool for early
skin cancer detection, thereby facilitating timely and effective medical interventions.
Chapter 2
Hardware Specifications:
Software Specifications:
Non-functional requirements are requirements that are not directly concerned with
the specific functions delivered by the system. The plan for implementing functional
requirements is detailed in the system design. The plan for implementing non-
functional requirements is detailed in the system architecture.
Performance: The code should be optimized to provide efficient and fast processing
of images during both training and inference. It should be able to handle a large
number of images without significant delays.
Accuracy: The image classification model should achieve a high level of accuracy
in predicting the correct class labels for the images. The code should aim to achieve
state-of-the-art performance in terms of classification accuracy.
Usability: The code should be user-friendly, providing clear instructions and error
messages to guide users in its usage. It should have well-defined input and output
formats, making it intuitive for users to interact with the system.
Reliability: The code should be robust and reliable, handling unexpected scenarios
and errors gracefully. It should incorporate error handling mechanisms and provide
appropriate error messages to users.
Chapter-3
METHODOLOGY
3.1 Datasets
The success of any machine learning project heavily relies on the quality and
diversity of the dataset used for training and evaluation. In our skin cancer detection
project, we meticulously curated a dataset that encapsulates the spectrum of benign
and malignant skin lesions. The dataset serves as the foundation for model training,
validation, and testing, ensuring the robustness and generalization of our deep learning
model.
The skin cancer dataset used in this project comprises a total of 2637 samples. The
dataset is meticulously curated to facilitate the training and evaluation of a deep
learning model for skin cancer detection. The samples are categorized into two classes:
This comprehensive dataset forms the foundation for the development and evaluation
of an accurate and clinically relevant skin cancer detection system.
Model Training:
Objective: Train the model using the provided training data and evaluate it on the
validation set. Adjust the model's weights based on the computed gradients.
train_gen: The training generator (train_gen) yields batches of augmented and
preprocessed images along with their labels.
validation_data=valid_gen: The validation generator (valid_gen) provides batches of
validation data to assess the model's performance during training.
epochs=100: The model is trained for a maximum of 100 epochs.
callbacks=my_callbacks: Early stopping is employed as a callback during training.
These data preprocessing steps collectively ensure that the model is trained on a varied
and well-prepared dataset, promoting better generalization to new, unseen skin lesion
images.
In summary, the main classification algorithm used in the code is the softmax
classifier, which assigns class probabilities to input data using the softmax activation
function. The model is trained to minimize the categorical cross-entropy loss, allowing
it to make accurate predictions for multi-class classification tasks.
Chapter 4
Performance Analysis
Malignant
- - 0.87 660
Accuracy
Precision:
Benign Class (0.88): Of all instances predicted as benign, 88% were correctly
classified.
Malignant Class (0.85): Of all instances predicted as malignant, 85% were correctly
classified.
Recall (Sensitivity):
Benign Class (0.87): Of all actual benign instances, the model correctly identified
87%.
Malignant Class (0.87): Of all actual malignant instances, the model correctly
identified 87%.
F1-Score:
Benign Class (0.88): The harmonic mean of precision and recall for the benign class
is 88%.
Malignant Class (0.86): The harmonic mean of precision and recall for the malignant
class is 86%.
Support:
Benign Class (353): The number of actual instances of the benign class.
Malignant Class (307): The number of actual instances of the malignant class.
Accuracy (Overall Correct Predictions):
Accuracy (0.87): The proportion of correctly classified instances out of the total
(benign and malignant).
The model shows good precision, recall, and F1-score for both benign and malignant
classes.
The balanced values indicate that the model is performing well for both classes without
a significant bias towards one.
An accuracy of 87% suggests that the model is generally effective in classifying skin
lesions as benign or malignant.
Chapter 5
TESTING
Data Splitting:
The dataset is split into training and testing sets using train_test_split from scikit-learn.
ImageDataGenerator : ImageDataGenerator is used for preprocessing during the
testing phase, ensuring consistency with the preprocessing applied during training.
Model Evaluation:
The trained model is evaluated on the test set using the evaluate method.
Metrics such as accuracy, loss, precision, recall, and F1-score are computed to assess
the model's performance.
Results Analysis:
The classification report is generated using scikit-learn's classification_report function,
providing detailed metrics for each class (benign and malignant).
Visualization:
Matplotlib is utilized to visualize the model's performance, including accuracy and loss
trends over epochs.
Chapter 6
Fig 6.1
Fig 6.1 show us the section of code where we are uploading the image i.e in
custom_image_path. We can see that we have already loaded our trained mode in order
to predict the custom images.
Fig 6.2
Fig 6.2 shows us some custom images which are downloaded from the internet. We
are using these images for our model to make the predictions.
Fig 6.3
Fig 6.3 shows us the classified image after running the model. In this case we have
uploaded the image of Malignant skin cancer and as we can see, the model predicted
it correctly .
Chapter 7
CONCLUSION
In conclusion, the skin cancer detection project has successfully implemented a
Convolutional Neural Network (CNN) with transfer learning using ResNet50,
showcasing robust performance in classifying skin lesions as benign or malignant. The
model exhibits commendable accuracy, precision, recall, and F1-score on a diverse
dataset. The utilization of data augmentation, transfer learning, and meticulous
preprocessing contributes to the model's ability to generalize well across various
scenarios.
The project's visualizations provide insights into the model's training dynamics and
performance metrics. Additionally, the incorporation of early stopping enhances
efficiency by preventing overfitting during training. The successful deployment of the
model is demonstrated through real-time predictions on custom skin lesion images.
Future Scope :
• Fine-Tuning and Hyperparameter Optimization: Explore further fine-tuning of
hyperparameters to potentially enhance model performance.
Chapter 8
REFERENCES
Kaggle Dataset :
https://www.kaggle.com/datasets/kmader/skin-cancer-mnist-ham10000
TensorFlow Tutorial :
https://www.tensorflow.org/tutorials/images/cnn
https://www.oreilly.com/library/view/hands-on-machine-learning/9781098125967/
YouTube Tutorial :
https://youtu.be/2OXV9MiATOY?si=iayLvdpja9EqHxtD