This project implements a deep learning pipeline for detecting metastatic cancer in small histopathology image patches.
It focuses on handling .tif images efficiently, training a binary classifier, and generating predictions for Kaggle’s Histopathologic Cancer Detection competition.
- Task: Binary classification — predict if the center 32×32 px region of a 96×96 px patch contains tumor tissue.
- Input:
.tifpathology image patches - Output: Probability of tumor presence
- Metric: ROC AUC
-
All images are provided as
.tiffiles. -
Labels are in
train_labels.csvwith columns:id: image ID, mapping totrain/{id}.tiflabel:1for tumor,0for normal
Example:
| id | label |
|---|---|
| 0005f7aaab2800f6170c399693a96917 | 0 |
| 000620e7e8e9ff9e6b4b27a84ebf2f8c | 1 |
- Custom loaders handle 8/16-bit
.tifimages and normalize them to float32[0,1]. - Automatically ensures RGB output.
- Loads and checks label distribution.
- Validates that all
.tiffiles exist. - Visualizes sample positive and negative patches.
- Uses Albumentations for strong data augmentation.
- Custom
Datasetclass reads.tiffiles and converts them to tensors.
- EfficientNet-B0 (from
timm) is used as the backbone. - Outputs a single logit for binary classification.
- Stratified K-Fold cross-validation.
- Binary cross-entropy loss and ROC AUC metric.
- Saves the best checkpoint per fold.
- Test-time augmentation (TTA) improves performance.
- Combines predictions from multiple folds.
- Generates a final
submission.csvfor Kaggle.
| Experiment | Model | Augmentations | Epochs | OOF AUC |
|---|---|---|---|---|
| Baseline | EfficientNet-B0 | Standard | 3 | ~0.95 |
| +TTA | EfficientNet-B0 | Extended | 3 | ~0.96 |
- Larger backbones or higher resolution inputs
- Stain-aware normalization or augmentation
- Class weighting or focal loss
- Semi-supervised learning with pseudo-labeling
- Model ensembling
- ✅
submission.csv— ready for Kaggle submission - ✅ Full
.ipynbtraining & inference notebook - ✅ Example visualizations and metrics