The model is a ResNet-18 CNN that has been pre-trained on the ImageNet dataset. The goal is to classify MRI images into four categories: glioma, meningioma, pituitary, and no tumor.
Kaggle Dataset: https://www.kaggle.com/datasets/masoudnickparvar/brain-tumor-mri-dataset
- Transfer Learning: Uses a pre-trained ResNet-18 model to leverage learned features from a large dataset.
- Data Augmentation: Applies transformations like random resized cropping and horizontal flipping to the training data to increase its diversity.
- Early Stopping: Monitors the validation accuracy and stops training if there is no improvement for five consecutive epochs.
The model is trained using the AdamW optimizer and cross-entropy loss with label smoothing. A learning rate scheduler (ReduceLROnPlateau) is used to adjust the learning rate during training. The final evaluation is performed on a separate test set, and the results are visualized with a confusion matrix.
-
Set up the environment:
pip install -r requirements.txt
-
Organize the data: Place the training and testing datasets in the
data/directory, following the structure below:data/ ├── Training/ │ ├── glioma/ │ ├── meningioma/ │ ├── notumor/ │ └── pituitary/ └── Testing/ ├── glioma/ ├── meningioma/ ├── notumor/ └── pituitary/ -
Run the notebook: Open and run the
notebook.ipynbfile in thesrc/directory to train the model and see the results.