This project uses a Convolutional Neural Network (CNN) to classify brain CT scans as either normal or hemorrhage. It's a practical deep learning application for medical image classification, implemented using TensorFlow and Keras.
The aim is to train a deep learning model that can accurately detect hemorrhages in CT scan images of the brain. This is critical in medical diagnostics, where rapid identification can be life-saving.
Deep Learning, particularly Convolutional Neural Networks (CNNs), excels at tasks involving image recognition. In medical imaging, CNNs can learn complex visual patterns to assist radiologists by automating the detection process.
- 140 training images: 70 normal, 70 hemorrhage
- 60 validation images: 30 normal, 30 hemorrhage
- 10 test images for final evaluation
- Organized in directory format for use with Keras'
ImageDataGenerator
Folder structure: data/ βββ head_ct_slices/ β βββ train/ β β βββ normal/ β β βββ hemorrhage/ β βββ validate/ β β βββ normal/ β β βββ hemorrhage/ β βββ test/
We built a deep CNN using the following structure: Input (150x150x3) β Conv2D(16) + MaxPool β Conv2D(32) + MaxPool β Conv2D(64) + MaxPool β Conv2D(64) + MaxPool β Conv2D(128) + MaxPool β Flatten β Dense(256, ReLU) β Dense(1, Sigmoid) Each convolution layer extracts features. Pooling layers reduce spatial size and computation. Final layers interpret these features to classify the image.
Epochs: 10 Optimizer: Adam Loss: Binary Crossentropy Metric: Accuracy
Training output includes:
accuracyandval_accuracyfor performance trackinglossandval_lossto monitor potential overfitting
After training, the model is tested on unseen test images. It predicts each image as either "normal" or "hemorrhage" based on a probability threshold of 0.5:
if prediction < 0.5:
print("Hemorrhage")
else:
print("Normal")- How to use
ImageDataGeneratorfor medical images - Building and tuning CNN layers for feature extraction
- Interpreting model predictions
- Importance of validation and test sets in medical AI
This project is designed as both a practical demo and a learning tool.
All steps and code are explained in plain language in the script file so that learners can follow along.