Brain Tumor Detection
Last updated
Last updated
With the growing use of machine learning (ML) in healthcare, we set out to create an image classification model that could potentially help doctors identify brain tumors.
The model we came up with is trained to take a brain scan image as input and classify whether or not a brain tumor is present in the image.
We grabbed the training images from this Kaggle project and pre-processed each of them into a resolution of 232x300 pixels. Below are a couple of examples of these images:
To use the images in PerceptiLabs, we first created a .csv file that maps the images to the labels: yes (i.e., contains a brain tumor) and no (does not contain a brain tumor). The following shows an example of what this .csv file contains:
images | labels |
yes/Y38.jpg | yes |
no/no 3.jpg | no |
This .csv file and the brain scan images are available on GitHub.
We then loaded the .csv file into the Data Wizard, setting the first column to images and the second column to categorical. We used the default data partitioning of 70% training, 20% validation, and 10% test, with randomization enabled, and left the default training values provided by the Data Wizard. The goal at this point was to generate a model that we could then modify.
After the model was generated, we went to work replacing the Components to end up with the following model architecture:
---------------------------------------------------------------------------------------------------------------------
Component 1: VGG16
---------------------------------------------------------------------------------------------------------------------
Component 2: Dense Activation=ReLU, Neurons=128
---------------------------------------------------------------------------------------------------------------------
Component 3: Dense Activation=Softmax, Neurons=2
---------------------------------------------------------------------------------------------------------------------- The following shows what this model looks like in PerceptiLabs:
When then trained the model with the following settings:
Epochs: 10
Batch size: 4
Loss: Cross-Entropy
Learning Rate: 0.001
Optimizer: ADAM
With a training time of less than 10 minutes, we achieved a training accuracy of 96.05% and a validation accuracy of 90%. In the following screenshot from PerceptiLabs you can see how the training accuracy ramped up over the first three epochs and then stabilized, while validation accuracy dipped around the third epoch before rising again and stabilizing:
In the realm of diagnosing brain tumors, a model like this could be used to help automate the process of examining brain scans and to notify doctors as to which cases may require a closer look.
Such a project could also be used by medical students or practitioners looking to build next-generation ML-based medical technology. The model itself could also be used as the basis for transfer learning to create additional models for detecting other types of tumors.
In the following video, we demonstrate how to set up this model in PerceptiLabs: