Domain-invariant Representation Learning via Segment Anything Model for Blood Cell Classification

Yongcheng Li, Lingcong Cai, Ying Lu, Cheng Lin, Yupeng Zhang, Jingyan Jiang, Genan Dai, Bowen Zhang, Jingzhou Cao, Xiangzhong Zhang, Xiaomao FanarXiv 2024

Abstract

Accurate classification of blood cells is of vital significance in the diagnosis of hematological disorders. However, in real-world scenarios, domain shifts caused by the variability in laboratory procedures and settings result in a rapid deterioration of the model's generalization performance. To address this issue, we propose a novel framework of domain-invariant representation learning (DoRL) via segment anything model (SAM) for blood cell classification. The DoRL comprises two main components: a LoRA-based SAM (LoRA-SAM) and a cross-domain autoencoder (CAE). The advantage of DoRL is that it can extract domain-invariant representations from various blood cell datasets in an unsupervised manner. Specifically, we first leverage the large-scale foundation model of SAM, fine-tuned with LoRA, to learn general image embeddings and segment blood cells. Additionally, we introduce CAE to learn domain-invariant representations across different-domain datasets while mitigating images' artifacts. To validate the effectiveness of domain-invariant representations, we employ five widely used machine learning classifiers to construct blood cell classification models. Experimental results on two public blood cell datasets and a private real dataset demonstrate that our proposed DoRL achieves a new state-of-the-art cross-domain performance, surpassing existing methods by a significant margin.

The Challenge of Domain Shift in Hematology

In clinical hematology, automated blood cell classification is essential for diagnosing conditions like leukemia and anemia. While deep learning models excel on specific datasets, they often struggle in real-world clinical environments due to domain shift. This phenomenon occurs because different laboratories utilize varying staining protocols (e.g., Wright-Giemsa vs. May-Grünwald), microscope resolutions, and lighting conditions.

Domain shift illustrated by pixel intensity variations across datasets and the resulting performance drop in standard models.

As shown in the figure above, pixel intensity distributions vary significantly between datasets like Matek-19 and Acevedo-20. Consequently, a model trained on one hospital's data often experiences a dramatic drop in accuracy—sometimes as much as 77%—when deployed at another facility. Existing unsupervised domain adaptation methods frequently fail to account for laboratory-specific image artifacts that can mislead classifiers.

The DoRL Framework

To overcome these challenges, the authors propose DoRL (Domain-invariant Representation Learning), a two-stage framework designed to extract morphological features while filtering out site-specific noise.

Overview of the DoRL framework, illustrating the pipeline from input blood cell images to final classification.

1. LoRA-SAM

The framework leverages the Segment Anything Model (SAM), a powerful vision foundation model. To adapt SAM for specialized medical imagery without prohibitive computational costs, the researchers use Low-Rank Adaptation (LoRA). By fine-tuning on just 1% of annotated blood cell images, they create a "LoRA-SAM" capable of generating high-quality image embeddings and precise segmentation masks.

2. Cross-domain Autoencoder (CAE)

This module extracts features that remain consistent across different datasets using an asymmetric encoder-decoder structure:

  • Encoder: Compresses the SAM embeddings into a latent space.
  • Decoder: Is tasked with reconstructing the segmented blood cell image rather than the original. This forces the model to ignore background textures and staining tints, focusing purely on cell morphology.
  • MMD Loss: Maximum Mean Discrepancy (MMD) is used to minimize the statistical distance between features from different datasets, ensuring the learned representations are truly domain-invariant.

Finally, these "clean" features are fed into standard machine learning classifiers such as SVM, Random Forest, or XGBoost for the final diagnostic output.

Experimental Validation

The study evaluated DoRL across three distinct datasets:

  • Matek-19: ~18,000 images (100x magnification).
  • Acevedo-20: ~17,000 images produced with different staining and hardware (Sysmex SP1000i).
  • SYSU3H: A private, real-world dataset from the Third Affiliated Hospital of Sun Yat-sen University.

Key Results

  • State-of-the-Art Performance: DoRL (with a linear SVM) achieved an average cross-domain accuracy of 60.36%, outperforming the previous best method by nearly 10%.
  • Robustness: When trained on Matek-19 and tested on the unseen Acevedo-20 dataset, DoRL-SVM maintained 63.18% accuracy, while a standard ResNext model's performance collapsed to 19.63%.
  • Feature Clarity: t-SNE visualizations confirmed that DoRL features form much tighter, more distinct clusters for different cell types compared to traditional domain adaptation methods.

Conclusion and Future Work

DoRL demonstrates that large-scale foundation models like SAM can be effectively repurposed for niche medical tasks with minimal data. By using reconstruction as a filter, the model successfully isolates intrinsic morphological features from laboratory-specific artifacts. Future research will focus on optimizing the Vision Transformer (ViT) architectures within the encoder and testing the framework on larger, more diverse "in-the-wild" clinical datasets to further validate its scalability.

Summary updated

BibTeX
@misc{li2024domain,
  author = {Yongcheng Li and Lingcong Cai and Ying Lu and Cheng Lin and Yupeng Zhang and Jingyan Jiang and Genan Dai and Bowen Zhang and Jingzhou Cao and Xiangzhong Zhang and Xiaomao Fan},
  title = {{Domain-invariant Representation Learning via Segment Anything Model for Blood Cell Classification}},
  year = {2024},
  eprint = {2408.07467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.07467},
}
Figure