This project demonstrates how you can use the TensorFlow Python library to build a deep learning model for image classification. The goal was to create a convolutional neural network that can process brain image scans and determine if a tumor is present.
The image dataset used to train the model was downloaded from Kaggle. The user, who uploaded the dataset, described the images as "X-ray images of Brain." However, these can be more accurately characterized as CT scans, since a basic X-ray scan is meant to visualize dense bone structures, like the skull. The images from dataset highlight the soft tissues inside the brain, which is more consistent with the features of a CT scan.
A model was trained on 80% of the data and evaluated on the other 20%. The final test accuracy came out to ~97%. This model was exported in the SavedModel format to \brain_tumor_detection_model\
, so anyone can load same the model and use it to make predictions on new images. To experiment with different model and training hyperparameters, follow the steps below to set up your environment.
- Clone the repository by running the command
git clone https://github.com/Nielam-Dass/Brain-Tumor-Detection.git
. - While in the project folder, create a virtual environment of your choice. This process may vary depending on your operating system. On Windows, run
python -m venv venv
, to create an environment folder namedvenv
. - Activate the environment with
venv\Scripts\activate.bat
. - Once the environment is active, install the necesary packages with
pip install -r requirements.txt
. - Go to the Kaggle website and generate an API token, which will be downloaded in JSON format. The file will contain values for the
username
andkey
fields. - Create a
.env
file in the project folder, which will define the environment variablesKAGGLE_USERNAME="your_username"
andKAGGLE_KEY="your_key"
according to the downloaded JSON data. - At this point, you can tweak the code in the Jupyter notebook to build and train a new model.
This project is designed for experimental purposes only! Any models created from this code (or a modified version of it) should NOT be used in a professional medical setting.