This project focuses on the classification of brain tumor images using convolutional neural networks (CNNs). It provides a pipeline for preprocessing the data, training different CNN models, and visualizing the results.
Demo_Trim.mp4
- Introduction
- Dependencies
- Data Preprocessing
- Model Training
- Visualizations
The goal of this project is to classify brain tumor images into four categories: glioma tumor, no tumor, meningioma tumor, and pituitary tumor. The code provided performs the following steps:
- Importing necessary libraries for data processing, model training, and visualization.
- Defining global variables such as image size and label names.
- Creating functions for data augmentation and generators for training and testing data.
- Building a CNN model using various pre-trained architectures like EfficientNet, VGG, MobileNet, ResNet, etc.
- Compiling the model with an optimizer, loss function, and metrics.
- Training the model using the training generator and validating with the validation generator.
- Saving the best model and logging the training progress.
- Visualizing the training history and model performance.
The code requires the following libraries to be installed:
- pickle
- matplotlib
- numpy
- h5py
- tensorflow
- seaborn
- cv2
- tqdm
- os
- scikit-learn
- ipywidgets
- Pillow
- pandas
- plotly
You can install the dependencies using pip:
pip install -r requirements.txt
Before training the model, it is recommended to perform some preprocessing steps on the data. The code provides functions for renaming files, augmenting the training data, and resizing and shuffling the test data. You can uncomment the relevant code sections and modify the file paths according to your data location.
The code includes different pre-trained CNN models such as EfficientNet, VGG, MobileNet, ResNet, etc. You can choose the desired architecture by uncommenting the corresponding code block. The model is compiled with an optimizer and loss function, and various callbacks are used for monitoring and saving the best model during training. You can adjust the hyperparameters such as learning rate, batch size, and number of epochs according to your requirements. To start training the model, uncomment the relevant code section and run the script. The model will be trained on the augmented training data and validated using the test data.
After training the model, you can visualize the training history and model performance. The code provides functions for reading the training logs and plotting the validation accuracy and loss over epochs using Plotly. You can uncomment the relevant code sections and modify the file paths to visualize the results of different models.