This repository contains a deep learning-based solution for classifying brain tumors using MRI images. The model is trained to classify images into four categories: No Tumor, Pituitary, Glioma, Meningioma
This project uses a Convolutional Neural Network (CNN) implemented in PyTorch to classify brain MRI images. The model architecture consists of multiple convolutional, batch normalization, max-pooling layers followed by fully connected layers.
The dataset used is the Brain Tumor MRI Dataset available on Kaggle. It contains MRI images for training and testing the model.
- Python 3.x
- PyTorch
- Torchvision
- NumPy
- Scikit-learn
- Matplotlib
- Seaborn
- Streamlit
The training script preprocesses the images, defines the model architecture, and trains the model.
- Preprocessing: Images are resized and normalized.
- Model Architecture: Defined in
model.py
. - Training Loop: Defined in the notebook with performance metrics.
The trained model is evaluated on a validation set, and the best-performing model is saved. The evaluation metrics include accuracy and loss.
A Streamlit application has been developed to facilitate the deployment of the model and enable predictions on new MRI images. The app can be accessed here.
- Model Loading: The pre-trained model is loaded automatically upon accessing the app.
- Image Upload: Users can upload MRI images directly to the app interface.
- Prediction Display: Once an image is uploaded, the app displays the predicted tumor type based on the model's classification.
The Streamlit app provides a user-friendly interface for interacting with the model and obtaining predictions effortlessly.
Run the Streamlit app:
streamlit run app.py
Project.Demo.mp4
- Clone the repository:
git clone https://github.com/HalemoGPA/BrainMRI-Tumor-Classifier-Pytorch.git
cd BrainMRI-Tumor-Classifier-Pytorch
- Install dependencies:
pip install -r requirements.txt
- Run the Streamlit app:
streamlit run app.py
The model achieves an accuracy of 99.3% on the test set. Training and validation loss and accuracy plots are provided to visualize the model's performance. Confusion matrices illustrate the classification performance on the test set.
- The dataset is provided by MASOUD NICKPARVAR on Kaggle.
- This project uses PyTorch for building and training the model.
The model training and evaluation process is detailed in this Kaggle Notebook.