This project uses a Convolutional Neural Network (CNN) implemented in TensorFlow/Keras to classify brain cancer types based on medical images. The model identifies three categories of brain cancer: Brain Glioma, Brain Menin, and Brain Tumor.
The dataset is expected to follow a directory structure compatible with ImageDataGenerator
:
/Multi Cancer
/Brain Cancer
/brain_glioma
- image1.jpg
- image2.jpg
...
/brain_menin
- image1.jpg
- image2.jpg
...
/brain_tumor
- image1.jpg
- image2.jpg
...
-
Install the required libraries:
- TensorFlow:
pip install tensorflow
- Matplotlib:
pip install matplotlib
- NumPy:
pip install numpy
- TensorFlow:
-
Download the dataset and place it in the correct directory structure as shown above.
- Place your images in the appropriate folder for each category (
brain_glioma
,brain_menin
,brain_tumor
). - Run the script to train the model and evaluate performance.
The model consists of the following layers:
- Conv2D layer with 32 filters, 3x3 kernel size, and ReLU activation.
- MaxPooling2D layer with 2x2 pool size.
- Conv2D layer with 64 filters, 3x3 kernel size, and ReLU activation.
- MaxPooling2D layer with 2x2 pool size.
- Conv2D layer with 128 filters, 3x3 kernel size, and ReLU activation.
- MaxPooling2D layer with 2x2 pool size.
- Flatten layer to convert the 2D output into 1D.
- Dense layer with 128 neurons and ReLU activation.
- Dense layer with the number of output neurons equal to the number of classes (3) and softmax activation.
The script will plot the training and validation accuracy over the epochs and display a sample image with the predicted and true labels.