Building a Skin Lesion Classification Web App

After adding a fully connected layer and through only training the last few layers, we obtain a model that can effectively identify basic features but make predictions that generalize well with relevant data.A diagram depicting the use of transfer learning to retrain layers of a network. Source.The Keras Applications library includes several deep learning models including VGG16, VGG19, ResNet50, MobileNet, and a few others..All of them have been trained on the ImageNet dataset which includes approximately 14 million images..That’s a pretty noticeable difference when compared to our 10,000-image dataset.For this project, I chose to use the MobileNet architecture, which is optimized for mobile applications with less computing power..This architecture makes use of depth-wise separable convolutions which essentially helps to reduce the number of training parameters, making the model more lightweight..For more information on MobileNet, check out this paper.Here’s how we can do it in Keras.Preprocessing the Images of Skin LesionsOne nice thing about the HAM10000 dataset is that all of the images are the same size, 600×450..However, after looking at the distribution of the images, we see that a significant majority of the images belong to the class of melanocytic nevi.Left: total number of images in each class..Right: number of training images in each class.Augmenting the Training DataData augmentation is super useful when it comes to increasing the number of training examples we can work with..We can augment the training data and For this, we use the Keras ImageDataGenerator class from the Keras Preprocessing library, which generates batches of tensor image data with real-time augmentation by looping through the data in batches..Some of the parameters that we pass through are:rotation_range: which is the degree range for random rotationswidth_shift_range: this represents a fraction of the total width that the image can be shifted byheight_shift_range: this represents a fraction of the total height that the image can be shifted byzoom_range=0.1: the fraction of the image that can be zoomed in or outhorizontal_flip=True: randomly flips the input horizontallyvertical_flip=True: randomly flips the input verticallyfill_mode='nearest': the specification for filling in points outside of the input boundariesWe can declare an augmented data generator by running the following code..Our target size is 224×224 because those are the dimensions that are needed for the MobileNet input layer.Compiling the ModelThe Keras Callbacks library provides a bunch of useful functions that can be applied at several stages during the training process of the model..These functions can be used to learn more about the internal states of the model..Two of the callbacks that are used in this program are ReduceLROnPlateau and ModelCheckpoint.ReduceLROnPlateau is used to reduce the learning rate when one of the model metrics has stopped improving.. More details

Leave a Reply