Contrastive fine-tuning against stain and scanner bias improves robustness and downstream performance across pathology foundation models
Abstract
Histopathology foundation models achieve strong performance across diverse downstream tasks, yet their representations have been shown to encode scanner- and site-specific biases, creating generalization gaps and potentially limiting real-world utility. We introduce SPECTRA (Scanner and Pathology Embedding Contrastive Tuning for Robust Alignment), a model-agnostic contrastive learning framework which explicitly encourages scanner- and stain-robust representations, to optimize performance and generalization on downstream applications. Using parameter-efficient LoRA adapters trained on matched multi-scanner and multi-stain whole-slide images sourced from the PLISM dataset, our method aligns representations of same-location, different-scanner regions while repelling different-location, same-scanner regions. SPECTRA improved PathoROB robustness index, gene-expression prediction on HEST, slide-level classification AUC on CPTAC, and held-out PLISM retrieval for every model. Overall tile-level classification on THUNDER also improved, with exceptions for segmentation and calibration tasks. We open-source our training and evaluation codebases and release adapters and model weights for selected backbones.