Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedVision

Python PyTorch License

Drug-efficacy studies in oncology depend on accurate tissue segmentation — you can't measure the tumor microenvironment, count infiltrating lymphocytes, or quantify stromal response if a pathologist (or a model) can't reliably tell tumor from stroma from background. This project does that for colorectal cancer histology with a small EfficientNet-B0.

EfficientNet-B0 (pretrained on ImageNet) fine-tuned to classify H&E-stained tissue patches into 9 classes, achieving 99.6% validation accuracy on the NCT-CRC-HE-100K benchmark — above the published state-of-the-art range of 94–97%.

Built with PyTorch and timm.


Results

Trained on 80/20 split. Early stopped at epoch 15/30.

Validation accuracy: 99.6%

Class F1 Score
ADI 1.00
BACK 1.00
DEB 1.00
LYM 1.00
MUC 0.99
MUS 1.00
NORM 1.00
STR 0.99
TUM 0.99

Confusion Matrix


Dataset

NCT-CRC-HE-100K — 100,000 histological image patches (224×224) of human colorectal cancer tissue across 9 classes:

  • ADI — Adipose
  • BACK — Background
  • DEB — Debris
  • LYM — Lymphocytes
  • MUC — Mucus
  • MUS — Smooth muscle
  • NORM — Normal colon mucosa
  • STR — Cancer-associated stroma
  • TUM — Colorectal adenocarcinoma epithelium

Architecture

  • EfficientNet-B0 backbone via timm, pretrained on ImageNet
  • Dropout (0.3) + linear classification head
  • AdamW optimizer with cosine annealing LR schedule
  • Mixed precision training (fp16) on CUDA
  • Data augmentation via Albumentations: flips, rotations, color jitter, blur
  • Early stopping with patience of 5 epochs

Setup

pip install -r requirements.txt

Set dataset path:

export MEDVISION_DATA_DIR="/path/to/NCT-CRC-HE-100K"

The directory should contain class subfolders directly (ADI/, BACK/, ..., TUM/).


Usage

Train:

python main.py

Evaluate — prints classification report and saves confusion matrix:

python evaluate.py

TensorBoard:

tensorboard --logdir runs

All hyperparameters are in config.py.


Reproducibility

To reproduce the reported results:

  1. Download NCT-CRC-HE-100K from Zenodo
  2. Set MEDVISION_DATA_DIR to the dataset root
  3. Run python main.py — training will early stop around epoch 15
  4. Run python evaluate.py to generate the classification report and confusion matrix

Training was run on an NVIDIA GeForce GTX 1660 Ti (CUDA 12.1). CPU training is supported but significantly slower.


Project Structure

medvision/
├── config.py              # hyperparameters and paths
├── main.py                # training entry point
├── evaluate.py            # evaluation and confusion matrix
├── data/dataset.py        # augmentations and dataloaders
├── models/classifier.py   # efficientnet + classification head
├── training/trainer.py    # train/val loop, checkpointing
├── utils/metrics.py       # sklearn metrics wrappers
├── utils/visualization.py # confusion matrix and curve plots
└── results/               # saved figures

License

MIT

About

Histology tissue classification using EfficientNet and PyTorch

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages