An automated medical imaging system designed to detect and classify brain tumors from MRI scans using Convolutional Neural Networks (CNN).
This project processes MRI images to classify them into one of 4 categories:
- Glioma
- Meningioma
- Pituitary
- No Tumor
We utilize a CNN architecture for feature extraction and classification, achieving high accuracy through K-Fold Cross Validation.
Ensure you have Python 3.8+ installed.
Run the following command to install all required libraries:
pip install -r requirements.txtKey Libraries used: tensorflow, pandas, numpy, matplotlib, seaborn, scikit-learn
Note: The dataset is not included in this repository.
- Place your dataset folder in the project root.
- Ensure it has the standard structure:
dataset/Training/glioma/ dataset/Training/meningioma/ dataset/Training/notumor/ dataset/Training/pituitary/ dataset/Testing/glioma/ dataset/Testing/meningioma/ dataset/Testing/notumor/ dataset/Testing/pituitary/ - Update the
DATASET_PATHvariable intrain_model.pyif your folder name is different.
Check the balance of the dataset to ensure fair training.
python data_analysis.pyOutputs: dataset_distribution.png (Bar chart of image counts)
Train the CNN using 5-Fold Cross Validation. This will generate training graphs and save the best model.
python train_model.pyOutputs:
tumor_detection_model.h5( The saved trained model)accuracy_fold_X.png&loss_fold_X.png(Training graphs)confusion_matrix_fold_X.png(Performance heatmaps)
Test the model yourself! This script opens a window where you can click "Next" to see predictions on random test images.
python interactive_eval.py(Requires tumor_detection_model.h5 to exist)
- Model: Custom Sequential CNN (3 Convolutional Blocks + Dropout).
- Input: 150x150 pixel MRI images.
- Validation: 5-Fold Cross Validation to ensure robustness.
- Metrics: We monitor Accuracy, Loss (Sparse Categorical Crossentropy), and Confusion Matrices.