Skip to content

White Blood Cell Classification is a deep learning project built with Python, TensorFlow, and Keras that classifies five types of WBCs from microscopic images using a CNN model. With advanced image preprocessing, data augmentation, and a robust architecture, it achieves up to 95% test accuracy.

Notifications You must be signed in to change notification settings

M-Husnain-Ali/White-Blood-Cell-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

🔬 White Blood Cell Classification using CNN

Python TensorFlow Keras Dataset Colab

A deep learning project implementing a Convolutional Neural Network (CNN) for automated classification of white blood cells from microscopic images, achieving 95% accuracy across five cell types.

Author: Muhammad Husnain Ali

🛠️ Technologies Used

Core Technologies

Data Processing & Model

🚀 Features

  • Advanced Image Processing

    • Automatic image resizing (128x128)
    • Pixel normalization
    • Data augmentation with rotations and flips
    • Balanced class distribution
  • Robust CNN Architecture

    • 4-stage convolutional network
    • Batch normalization
    • Dropout regularization
    • MaxPooling for feature selection
  • Performance Optimization

    • Early stopping
    • Learning rate scheduling
    • Model checkpointing
    • GPU acceleration
  • Comprehensive Evaluation

    • Confusion matrix analysis
    • ROC curve generation
    • Per-class accuracy metrics
    • Real-time prediction visualization

🏗️ Model Architecture

Input (128x128x3)
│
├── Conv Block 1 (64 filters) → BatchNorm → MaxPool → Dropout(0.25)
│
├── Conv Block 2 (128 filters) → BatchNorm → MaxPool → Dropout(0.25)
│
├── Conv Block 3 (256 filters) → BatchNorm → MaxPool → Dropout(0.25)
│
├── Conv Block 4 (512 filters) → BatchNorm → MaxPool → Dropout(0.25)
│
├── Dense(1024) → Dropout(0.5)
│
├── Dense(512) → Dropout(0.5)
│
└── Output(5) → Softmax

📊 Dataset

  • Source: White Blood Cells Dataset
  • Classes: 5 WBC types
    • Neutrophils
    • Eosinophils
    • Basophils
    • Monocytes
    • Lymphocytes
  • Volume: 14,514 images
    • Training: 8,140 (80%)
    • Validation: 2,035 (20%)
    • Test: 4,339

📈 Performance

Metric Score
Training Accuracy 93.73%
Validation Accuracy 94.94%
Test Accuracy 95.00%
Inference Time <100ms

🚀 Quick Start

1. Open in Colab

Open In Colab

2. Mount Google Drive

from google.colab import drive
drive.mount('/content/drive')

3. Install Dependencies

!pip install -r requirements.txt

4. Download Dataset

!kaggle datasets download -d paultimothymooney/blood-cells
!unzip blood-cells.zip

5. Run Training

!python train.py --epochs 10 --batch_size 32

📦 Requirements

tensorflow>=2.8.0
numpy>=1.19.5
opencv-python>=4.5.5
matplotlib>=3.4.3
scikit-learn>=1.0.2

💡 Usage Tips

Training

  • Use GPU runtime in Colab
  • Enable data augmentation
  • Start with provided hyperparameters
  • Monitor validation metrics

Prediction

model = load_model('wbc_classifier.h5')
prediction = model.predict(image)

Evaluation

from evaluation import evaluate_model
metrics = evaluate_model(model, test_data)

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

📞 Support

For questions and support:

🙏 Acknowledgments

  • Kaggle for the comprehensive dataset
  • TensorFlow team for the framework
  • Google Colab for free GPU resources
  • All contributors to this project

Made with ❤️ by Muhammad Husnain Ali

About

White Blood Cell Classification is a deep learning project built with Python, TensorFlow, and Keras that classifies five types of WBCs from microscopic images using a CNN model. With advanced image preprocessing, data augmentation, and a robust architecture, it achieves up to 95% test accuracy.

Topics

Resources

Stars

Watchers

Forks