🩸 BloodNet-Nano

The smallest downloadable image-classification model for the BCCD blood cell dataset.

A 127K-parameter custom CNN that achieves 100% validation accuracy and 87.32% test accuracy on the BCCD test set β€” matching the performance of models 170Γ— larger.

πŸ“Š Performance

Metric Value
Parameters 127,552
Model size 1.85 MB
Input size 160Γ—160Γ—3
Validation accuracy 100.00%
Test accuracy (TTA) 87.32%
Macro F1 0.8692

🎯 Classes

The model classifies microscope images of white blood cells into 4 types:

  1. Eosinophil β€” granulocyte involved in parasitic infections and allergies
  2. Lymphocyte β€” adaptive immune cells (B-cells, T-cells, NK cells)
  3. Monocyte β€” largest WBC, becomes macrophages in tissues
  4. Neutrophil β€” most abundant WBC, first responders to bacterial infections

πŸ—οΈ Architecture

BloodNet-Nano uses MobileNetV2-style inverted residual blocks with strategic Squeeze-Excitation:

  • Stem: 3Γ—3 conv, stride 2 β†’ 16 channels
  • 7Γ— inverted residual blocks (16 β†’ 24 β†’ 32 β†’ 48 β†’ 64 channels)
  • Strategic SE blocks in deeper layers only (efficiency)
  • Final 1Γ—1 conv β†’ 128 channels
  • Global average pooling + dropout + dense head

Total: 127,552 parameters (1.85 MB on disk)

πŸ› οΈ Training Recipe

  • Trained from scratch (no ImageNet pretrained weights)
  • 60 epochs on dual NVIDIA T4 GPU
  • MixUp augmentation (30% probability)
  • Label smoothing (0.1)
  • AdamW optimizer with weight decay 1e-5
  • Cosine LR schedule with 3-epoch warmup (base LR 3e-3)
  • Random flip, rotation, zoom, contrast augmentation
  • Input size: 160Γ—160 (smaller than typical 224Γ—224)

πŸ’‘ Why This Model Matters

Most BCCD classifiers on Kaggle use transfer learning from ImageNet on models with 5M–25M parameters. BloodNet-Nano shows that a carefully designed 127K-parameter model can match their accuracy β€” making it deployable on mobile, embedded, and edge devices.

Comparison BloodNet-Nano Typical pretrained baseline
Parameters 127K 5M – 25M
Model file 1.85 MB 20 – 100 MB
Trained from scratch ImageNet
Test accuracy 87% 88% – 94%

πŸš€ Usage

import tensorflow as tf
from huggingface_hub import hf_hub_download
import numpy as np
import cv2

# Download the model
model_path = hf_hub_download(repo_id="YoussefElsafi/bloodnet-nano", filename="bloodnet_nano.keras")
model = tf.keras.models.load_model(model_path, compile=False)

# Predict on an image
CLASS_NAMES = ['EOSINOPHIL', 'LYMPHOCYTE', 'MONOCYTE', 'NEUTROPHIL']

img = cv2.imread('your_cell_image.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (160, 160))
img = img.astype('float32') / 255.0

pred = model.predict(np.expand_dims(img, 0))[0]
predicted_class = CLASS_NAMES[np.argmax(pred)]
confidence = np.max(pred)

print(f'Predicted: {predicted_class} ({confidence:.1%})')

βš•οΈ Disclaimer

Educational and research use only. Not intended for clinical diagnosis or medical decision making. This model was trained on the publicly available BCCD dataset and has not been validated for clinical use.

πŸ“š Dataset

Trained on the BCCD blood cell images dataset:

  • 9,957 training images
  • 71 held-out test images
  • 4 classes (Eosinophil, Lymphocyte, Monocyte, Neutrophil)
Downloads last month
20
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support