![]() |
VOOZH | about |
We will learn how to implement a Skin Cancer Detection model using Tensorflow. We will use a dataset that contains images for the two categories that are malignant or benign. We will use the transfer learning technique to achieve better results in less amount of training.
Python libraries make it very easy for us to handle the data and perform typical and complex tasks with a single line of code.
Fetches all image file paths recursively from the dataset directory using glob or you can download dataset from kaggle.
Output:
2637
Standardizes file paths and creates a DataFrame mapping each image path to its label based on the directory.
Output:
Converting string labels into binary values (0 for benign, 1 for malignant) will save our work of label encoding.
Output:
Visualizes the proportion of benign vs malignant images using a pie chart.
Output:
An approximately equal number of images have been given for each of the classes so, data imbalance is not a problem here.
Displays a few sample images from each class for initial visual inspection.
Output:
Now, let's split the data into training and validation parts by using the train_test_split function.
Output:
((2241,), (396,))
Defines a function to load, decode, resize, and normalize image tensors.
Image input pipelines have been implemented below so that we can pass them without any need to load all the data beforehand.
Now as the data input pipelines are ready let's jump to the modeling part.
For this task, we will use the EfficientNet architecture and leverage the benefit of pre-trained weights of such large networks.
We will implement a model using the Functional API of Keras which will contain the following parts:
Output:
258076736/258076736 [==============================] - 3s 0us/step
While compiling a model we provide these three essential parameters:
Trains the CNN model using the training dataset and validates on the validation set.
Output:
Letβs visualize the training and validation loss and AUC with each epoch.
Output:
Output:
Training loss has not decreased over time as much as the validation loss.
Output:
Get the Complete Notebook from here.