Brain Tumor Detector part 2

Nelson Punch
Software-Dev-Explore
2 min readNov 9, 2023
Photo by National Cancer Institute on Unsplash

Introduction

The dataset is ready on Kaggle for training the deep learning model. However this dataset is required to be preprocessing before it can be used for training the model.

I written entire code inside Kaggle notebook.

Code

Netbook with code

Import libraries

Import necessary libraries and set parameters for training the model.

A note.

  • IMAGE_SIZE : the image size for training the model
  • BASE_LR : Initial learning rate for the model
  • EPOCH : Number of iteration the model will be trained

Preprocessing image

According to Kaggle dataset description, the images in this dataset need to be preprocessed.

Pay attention that The size of the images in this dataset is different. You can resize the image to the desired size after pre-processing and removing the extra margins. This work will improve the accuracy of the model pre-processing code

Fortunately it provide the code on how to do image preprocessing.

This corp function adapting pre-processing code and return a new image wich is resized to particular size.

I create a function that leverage corp function to do image preprocessing flow and save preprocessed images into another folder in disk.

This function copy all image and folder names to another directory and preprocess any images it encounter.

Finally I simply call image preprocessing function.

Conclusion

The method for preprocessing image is depending on what kind of dataset that is given. In this case the dataset provided an instruction on how to preprocessing dataset.

Next

The images in the dataset has been preprocessed and I need create a Tensorflow dataset from these preprocessed images.

part 3

--

--