Author: Rahul Trivedi
M.Tech ( ECE )
📩 rahultrivedi106@gmail.com
This repository presents a TensorFlow-based Convolutional Neural Network (CNN) for automatic Brain MRI image classification, distinguishing between Ischemic and Hemorrhagic stroke types.
A lightweight CNN model has been implemented and trained on a Kaggle MRI dataset, provided for demonstration and reproducibility.
Brain-MRI-Classification-TF-Final/
│
├── src/ # Model, evaluation & preprocessing scripts
│ ├── train_tf.py
│ ├── evaluate_tf.py
│ └── preprocess.py
│
├── data/ # MRI dataset (demo)
│ └── raw/
│ ├── train/
│ │ ├── ischemic/
│ │ └── hemorrhagic/
│ └── val/
│ ├── ischemic/
│ └── hemorrhagic/
│
figures/
├── model_architecture.png
├── training_curves.png
├── Ischemic_Stroke.jpg
├── Hemorrhagic_stroke.jpeg
├── Ischemic_pred_labeled.png
├── Hemorrhagic_pred_labeled.png
│
├── notebooks/ # Jupyter notebook (demo)
├── experiments/ # Model outputs
├── requirements.txt
├── LICENSE
└── README.md
A simple CNN built using Keras sequential API.
Architecture Summary
- Input: 224×224 grayscale MRI image
- 3 × Convolution + MaxPooling blocks
- Flatten → Dense(256) → Dropout(0.4)
- Output: Softmax (2 classes)
Each MRI scan is preprocessed (grayscale, 224×224, normalized) before training.
python -m venv venv
# For Linux/Mac
source venv/bin/activate
# For Windows
venv\Scripts\activatepip install -r requirements.txtpython src/train_tf.py --epochs 10 --batch_size 8Model weights will be saved to:
experiments/tf_model.h5
python src/evaluate_tf.pyTraining accuracy and validation accuracy show consistent convergence.
Pred: Ischemic (0.86) | Pred: Hemorrhagic (0.89)
Model accurately distinguishes between stroke types based on MRI input.
- Dataset included: Synthetic MRI dataset (Ischemic vs Hemorrhagic)
- Inspired by the Kaggle public dataset:
Brain MRI Images for Brain Tumor Detection
---
## 📈 Results Summary
| Metric | Value |
|--------|--------|
| Training Accuracy | ~92% |
| Validation Accuracy | ~88–90% |
| Loss | Stable (0.2–0.3) |
---
## 🧭 Pipeline Flow
**Data Loading → Preprocessing → Model Training → Validation → Evaluation → Visualization**

---
## 🧱 Dependencies
- tensorflow==2.12.0
- numpy
- pillow
- matplotlib
- scikit-learn
- opencv-python
- tqdm
📘 This project has been developed purely for educational and research purposes.
MIT License © 2025 Rahul Trivedi
Rahul Trivedi
📩 rahultrivedi106@gmail.com





