Skip to content

About

Deep learning project using TensorFlow CNN for Brain MRI image classification (Ischemic vs Hemorrhagic). Includes model training, evaluation, preprocessing, and result visualization.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🧠 Brain MRI Image Classification (TensorFlow)

TensorFlow Python License: MIT Status

Author: Rahul Trivedi
M.Tech ( ECE ) 📩 rahultrivedi106@gmail.com


📘 Overview

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.


📂 Directory Structure

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

🧩 Model Architecture

A simple CNN built using Keras sequential API.

Model Architecture

Architecture Summary

  • Input: 224×224 grayscale MRI image
  • 3 × Convolution + MaxPooling blocks
  • Flatten → Dense(256) → Dropout(0.4)
  • Output: Softmax (2 classes)

🧠 Sample MRI Input

🩺 Ischemic Stroke

Ischemic Stroke MRI

🧩 Hemorrhagic Stroke

Hemorrhagic Stroke MRI

Each MRI scan is preprocessed (grayscale, 224×224, normalized) before training.


⚙️ How to Run Locally

1️⃣ Create and activate virtual environment

python -m venv venv
# For Linux/Mac
source venv/bin/activate
# For Windows
venv\Scripts\activate

2️⃣ Install dependencies

pip install -r requirements.txt

3️⃣ Train model

python src/train_tf.py --epochs 10 --batch_size 8

Model weights will be saved to:

experiments/tf_model.h5

4️⃣ Evaluate model

python src/evaluate_tf.py

📊 Training Curves

Training Curves

Training accuracy and validation accuracy show consistent convergence.


🧾 Prediction Output Example

Predicted Ischemic Stroke Predicted Hemorrhagic Stroke

Pred: Ischemic (0.86)     |     Pred: Hemorrhagic (0.89)

Model accurately distinguishes between stroke types based on MRI input.


💾 Dataset Information


---

## 📈 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**

![Flowchart](figures/model_architecture.png)

---

## 🧱 Dependencies

- tensorflow==2.12.0  
- numpy  
- pillow  
- matplotlib  
- scikit-learn  
- opencv-python  
- tqdm  



📘 This project has been developed purely for educational and research purposes.

📜 License

MIT License © 2025 Rahul Trivedi


📧 Contact

Rahul Trivedi
📩 rahultrivedi106@gmail.com


About

Deep learning project using TensorFlow CNN for Brain MRI image classification (Ischemic vs Hemorrhagic). Includes model training, evaluation, preprocessing, and result visualization.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages