In the 2021 Data Science Institute Computer Vision Challenge, we applied semantic image segmentation techniques on magnetic resonance imaging (MRI) to aid the diagnosis of brain tumors. Prof. Yike Guo, the co-director of the Data Science Institute (DSI), and the DSI judging panel awarded this work as the winner of "Best Computer Vision Project". Since our model achieved the highest dice score (78%) in the testing tasks, which uses U-Net architecture with pre-trained VGG16, and was trained on 90% of the available data.
To provide solutions for real-world applications, I further developed it into a Tumor Segmentation API that could be accessed by doctors and clinicians for effective screening and diagnosis.
The datasets contain brain MRIs from glioma patients, MRI images (left) and matching masks (right) that have been annotated by the doctor, can be downloaded via URL.
The following are the major open source packages utilised in this project:
- Numpy
- Pandas
- OpenCV
- Matplotlib
- Scikit-Learn
- Pytorch
- TensorFlow
- Keras
- Flask
code
.
├── images # path to store images in tiff png gif
├── notebooks
│ ├── TumorSeg_Winner_U_Net_VGG16.ipynb # notebook to train VGG16 U-Net
│ ├── TumorSeg_API_U_Net_VGG19.ipynb # notebook to train VGG19 U-Net
│ └── README.md
│
├── static
│ ├── css
│ ├── img # path to store uploaded images
│ ├── js
│ └── Pred.png
│
├── templates # tempaltes for webapp development
│
│
├── api.py # API depolyment using Flask
├── test.py
├── requirements.txt
└── README.md
- Upload
Dataset
to Google Drive, dataset can be found here.
- (Optional) Create an account on Weights & Biases platform (The training is tracked by
wandb
, this is a tool for tracking and visualising machine learning experiments in real time. If you have an account on Weights & Biases, get started by copying the profile API key and pasting it later in the notebook as requested)
- Open notebook in Google Colab to train U-Net model
- Clone this repository, open a terminal and navigate to the directory to write the command
git clone https://github.com/xy2119/Brain_MRI_Image_Segmentation.git
cd Brain_MRI_Image_Segmentation
- Create and set up the environment
tumorseg
conda create --name tumorseg --file requirements.txt
- Activate
tumorseg
environment
conda activate tumorseg
-
Move the trained model to the current directory.
You are welcomed to deploy your own model, or download mine :) unet_vgg19.h5 <- testset dice score ~ 81% trained from here
- Run
api.py
script and visit the web address to try out the segmenting functions!
python api.py
Exploring more advanced segmentation models, like SEP and FCBFormer refer to the paperwithcode leaderboard.
If you have any questions or suggestions towards this repository, feel free to contact me at xy2119@ic.ac.uk.
Any kind of enhancement or contribution is welcomed!