Skip to content

abdelrhmanelruby/Brain-MRI-Tumor-and-Alzheimer-Classification

Repository files navigation

Brain-MRI-Tumor-and-Alzheimer-Classification

Please visit the following link to access the demo version: Brain-MRI-Tumor-and-Alzheimer-Classification

Brief overview

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.

Data

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. 

Testing datasets 

Sample images from Brain Tumor MRI Images 44 Classes dataset

sample_44 distribution_44

Sample images from Alzheimer MRI Preprocessed Dataset

sample_alzheimer distribution_alzheimer

Data augmentation

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.

Requirements

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 

Models

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)

Result

Brain Tumor MRI Images 44 Classes

EfficientNetB5_44_classes 96.5% accuracy on the test set

Brain Tumor MRI Images 17 Classes

EfficientNetB5_17calss 98.1% accuracy on the test set

Brain Tumor MRI Images 15 Classes

EfficientNetB5_15calss 99.8% accuracy on the test set

Brain_Tumor_Detection_MRI 2 Classes

EfficientNetB5_2calss_lagre_dataset 99.1% accuracy on the test set

Alzheimer MRI Preprocessed Dataset 4 Classes

alzheimer 99.5% accuracy on the test set

Deployment

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

Contributors

Thank you!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published