Please visit the following link to access the demo version: Brain-MRI-Tumor-and-Alzheimer-Classification
The goal of this project is to create a deep convolutional neural network model that can classify brain tumors and Alzheimer's disease using MRI scan images.
The architecture is a fully convolutional network (FCN) built upon several well-known models like ResNet50V2, VGG16, and EfficientNetb5.
For the main model, we used Brain Tumor MRI Images 44 Classes a collection of T1, contrast-enhanced T1, and T2 magnetic resonance images separated by brain tumor type. Contains a total of 4479 images and 44 classes.
We used this dataset to train our main CNN model and then tested it on different datasets. We used the same model and weights as the main model, with the only difference being the output layer.
- Brain Tumor MRI Images 44 Classes using only tumor types 4479 images and 15 classes
- Brain Tumor MRI Images 17 Classes contains 4448 images and 17 classes
- Brain Tumor Classification (MRI) contains 3264 images and 4 classes
- Brain MRI Images for Brain Tumor Detectioncontains 253 images and 2 classes
- Brain_Tumor_Detection_MRI contains 3060 images and 2 classes
- Alzheimer MRI Preprocessed Dataset contains 6400 images and 2 classes
rescale=1./255,
rotation_range=20,
width_shift_range=0.1,
height_shift_range=0.1,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest'
- Horizontal flip: basically, flips both rows and columns horizontally.
- Rotation_range: is a value in degrees (0-180), a range within which to randomly rotate pictures.
- Rescale: is a value by which we will multiply the data before any other processing. Our original images consist in RGB coefficients in the 0-255, but such values would be too high for our models to process (given a typical learning rate), so we target values between 0 and 1 instead by scaling with a 1/255. factor.
- Width_shift and Height_shift: are ranges (as a fraction of total width or height) within which to randomly translate pictures vertically or horizontally.
- Zoom_range: is for randomly zooming inside pictures.
- Shear_range: is for randomly applying shearing transformations.
- Fill_mode: is the strategy used for filling in newly created pixels, which can appear after a rotation or a width/height shift.
To run the code, you first need to install the following prerequisites:
Python 3.5 or above
tensorflow==2.9.1
keras==2.9.0
streamlit==1.14.0
streamlit_option_menu==0.3.2
numpy
pandas
matplotlib
You can find the model's layers with their weights in the huggingface repository.
from tensorflow import keras
Model = keras.models.load_model(model_path)
96.5% accuracy on the test set
98.1% accuracy on the test set
99.8% accuracy on the test set
99.1% accuracy on the test set
99.5% accuracy on the test set
Please visit the following link to access the app's demo version: https://huggingface.co/spaces/Longliveruby/Brain-MRI-Tumor-and-Alzheimer-Classification The website can be accessed and tested out there. Due to the limitations of file sizes and RAM limits, I decided to go with huggingface because the free version is not severely limited.
You can test the app on localhost by cloning the repository data, cd into the folder and run the following commands:
cd Streamlit
streamlit run main.py
Installing dependencies:
pip install -r requirements.txt