To build a CNN based model which can accurately detect melanoma. Melanoma is a type of cancer that can be deadly if not detected early. It accounts for 75% of skin cancer deaths. A solution that can evaluate images and alert dermatologists about the presence of melanoma has the potential to reduce a lot of manual effort needed in diagnosis.
The dataset consists of 2357 images of malignant and benign oncological diseases, which were formed from the International Skin Imaging Collaboration (ISIC). All images were sorted according to the classification taken with ISIC, and all subsets were divided into the same number of images, with the exception of melanomas and moles, whose images are slightly dominant.
The data set contains the following diseases:
-
Actinic keratosis
-
Basal cell carcinoma
-
Dermatofibroma
-
Melanoma
-
Nevus
-
Pigmented benign keratosis
-
Seborrheic keratosis
-
Squamous cell carcinoma
-
Vascular lesion
To classify skin cancer using skin lesions images. To achieve higher accuracy and results on the classification task, I have built custom CNN model.
-
Rescalling Layer - To rescale an input in the [0, 255] range to be in the [0, 1] range.
-
Convolutional Layer - Convolutional layers apply a convolution operation to the input, passing the result to the next layer. A convolution converts all the pixels in its receptive field into a single value. For example, if you would apply a convolution to an image, you will be decreasing the image size as well as bringing all the information in the field together into a single pixel.
-
Pooling Layer - Pooling layers are used to reduce the dimensions of the feature maps. Thus, it reduces the number of parameters to learn and the amount of computation performed in the network. The pooling layer summarises the features present in a region of the feature map generated by a convolution layer.
-
Dropout Layer - The Dropout layer randomly sets input units to 0 with a frequency of rate at each step during training time, which helps prevent overfitting.
-
Flatten Layer - Flattening is converting the data into a 1-dimensional array for inputting it to the next layer. We flatten the output of the convolutional layers to create a single long feature vector. And it is connected to the final classification model, which is called a fully-connected layer.
-
Dense Layer - The dense layer is a neural network layer that is connected deeply, which means each neuron in the dense layer receives input from all neurons of its previous layer.
-
Activation Function(ReLU) - The rectified linear activation function or ReLU for short is a piecewise linear function that will output the input directly if it is positive, otherwise, it will output zero.The rectified linear activation function overcomes the vanishing gradient problem, allowing models to learn faster and perform better.
-
Activation Function(Softmax) - The softmax function is used as the activation function in the output layer of neural network models that predict a multinomial probability distribution. The main advantage of using Softmax is the output probabilities range. The range will 0 to 1, and the sum of all the probabilities will be equal to one.
- We are required to build a multiclass classification model using a custom convolutional neural network in TensorFlow.
- Predicting a incorrect class of skin cancer
-
Data Reading/Data Understanding → Defining the path for train and test images
-
Dataset Creation→ Create train & validation dataset from the train directory with a batch size of 32. Also, make sure you resize your images to 180*180.
-
Dataset visualisation → Create a code to visualize one instance of all the nine classes present in the dataset
-
Model Building & training :
-
Create a CNN model, which can accurately detect 9 classes present in the dataset. While building the model, rescale images to normalize pixel values between (0,1).
-
Choose an appropriate optimiser and loss function for model training
-
Train the model for ~20 epochs
-
Write your findings after the model fit. You must check if there is any evidence of model overfit or underfit.
-
Chose an appropriate data augmentation strategy to resolve underfitting/overfitting
-
Model Building & training on the augmented data :
-
Create a CNN model, which can accurately detect 9 classes present in the dataset. While building the model rescale images to normalize pixel values between (0,1).
-
Choose an appropriate optimiser and loss function for model training
-
Train the model for ~20 epochs
-
Write your findings after the model fit, see if the earlier issue is resolved or not?
-
Class distribution: Examine the current class distribution in the training dataset
-
Which class has the least number of samples?
-
Which classes dominate the data in terms of the proportionate number of samples?
-
Handling class imbalances: Rectify class imbalances present in the training dataset with Augmentor library.
-
Model Building & training on the rectified class imbalance data :
-
Create a CNN model, which can accurately detect 9 classes present in the dataset. While building the model, rescale images to normalize pixel values between (0,1).
-
Choose an appropriate optimiser and loss function for model training
-
Train the model for ~30 epochs
-
Write your findings after the model fit, see if the issues are resolved or not?
-
pandas - 1.3.4
-
numpy - 1.20.3
-
matplotlib - 3.4.3
-
seaborn - 0.11.2
-
sklearn - 1.1.2
-
statsmodel - 0.13.2
-
tensorflow - 2.11.0
-
Introduction to CNN from https://www.analyticsvidhya.com/blog/2021/05/convolutional-neural-networks-cnn/
-
Image classification using CNN from https://www.analyticsvidhya.com/blog/2020/02/learn-image-classification-cnn-convolutional-neural-networks-3-datasets/
-
Efficient way to build CNN architecture from https://towardsdatascience.com/a-guide-to-an-efficient-way-to-build-neural-network-architectures-part-ii-hyper-parameter-42efca01e5d7
Created by [@abhikgupt] - feel free to contact me!