Medi-CAT: Contrastive Adversarial Training for Medical Image Classification

Pervaiz Iqbal Khan, Andreas Dengel, Sheraz Ahmed

TL;DR

Medi-CAT addresses the "Goldilocks problem" in medical imaging—where models are often either too small to learn complex features or too large for the limited data available—by combining pre-trained Vision Transformers with a joint adversarial and contrastive training objective. This approach significantly boosts classification accuracy across several MedMNIST benchmarks by improving feature robustness and preventing overfitting.

What Problem Does This Paper Address?

Deep learning in medicine faces a persistent hurdle: data scarcity. While large-scale datasets like ImageNet exist for general computer vision, medical datasets are often small and expensive to curate. This creates a dilemma. Small models often suffer from underfitting, failing to capture the nuanced discriminative features needed for diagnosis. Conversely, powerful large models, like Vision Transformers (ViTs), are prone to overfitting, essentially memorizing the small training set rather than learning to generalize to new patients.

The authors of Medi-CAT aim to bridge this gap. They seek to leverage the high capacity of large, pre-trained transformers while introducing specialized training techniques to ensure these models remain robust and generalizable despite limited medical data.

Methods

The proposed Medi-CAT (Contrastive Adversarial Training) framework integrates three core components into a unified training pipeline:

  1. Vision Transformer (ViT) Backbone: The system uses a pre-trained ViT-Large as the primary image encoder. ViTs are excellent at capturing long-range global dependencies in images that traditional CNNs might miss.
  2. Adversarial Training (AT): To improve robustness, the model doesn't just look at "clean" images. It uses the Fast Gradient Sign Method (FGSM) to generate perturbed, adversarial versions of the training data. By training on these "hard" examples, the model learns to ignore small, misleading pixel-level noise.
  3. Contrastive Learning (Barlow Twins): This is the "CAT" in Medi-CAT. The authors employ the Barlow Twins loss function. It works by taking the feature representations of a clean image and its adversarial counterpart and pulling them closer together in the representation space, while simultaneously pushing representations of different images apart. This forces the model to learn features that are invariant to noise.

The final training objective is a weighted sum of the classification losses for both clean and adversarial images, plus the contrastive loss.

Fig. 1: Proposed training methodology for medical image classification.

Datasets

The researchers evaluated Medi-CAT on four multi-class classification datasets from the MedMNIST v2 collection, a large-scale lightweight benchmark for 2D and 3D biomedical image classification:

  • DermaMNIST: Skin lesion images (7 classes).
  • OrganAMNIST: Abdominal CT scans (11 classes).
  • OrganCMNIST: Abdominal CT scans (11 classes).
  • OrganSMNIST: Abdominal CT scans (11 classes).
Table 1: Statistics of datasets from MedMNIST [24] collection used in our ex- periments .

Key Insights and Ideas

  • Synergistic Regularization: The combination of adversarial training and contrastive learning acts as a powerful regularizer. While AT provides "harder" data samples, the contrastive loss ensures the model focuses on the underlying semantic content rather than the noise.
  • The Shared Encoder Strategy: By using a shared encoder for both clean and noisy images, the model is forced to map both to a unified, robust feature space.
  • Sensitivity to Hyperparameters: The authors found that the balance between classification and contrastive loss ($\alpha$) is critical. Performance generally peaked at lower values of $\alpha$ (less weight on contrastive loss), with a sharp decline if the contrastive component became too dominant ($\alpha \ge 0.6$).
  • Dataset Difficulty: The impact of the method varied by dataset. For example, DermaMNIST appeared more sensitive to noise levels ($\epsilon$) and loss weighting than the OrganMNIST variants, suggesting that the "difficulty" or nature of the underlying images dictates how much noise-based training helps.

Key Results

Medi-CAT demonstrated superior performance compared to several well-known baselines, including standard ResNets, specialized medical transformers (MedViT), and large-scale multimodal models (BioMed-GPT).

  • State-of-the-Art (SOTA) Performance: The method outperformed existing approaches on three out of the four tested datasets.
  • Significant Gains: Compared to the baseline ViT-Large model, Medi-CAT increased accuracy by up to 4.1% on the DermaMNIST dataset.
  • Ablation Success: The authors showed that while Adversarial Training alone helps, the addition of the Contrastive component consistently provides the best results across almost all benchmarks.

Comparison of Medi-CAT with existing methods. Ablation study showing the impact of AT and Contrastive components.

Limitations and Future Work

  • Computational Cost: The primary drawback is the increased training cost. Generating adversarial examples via FGSM requires additional gradient calculations and forward passes, making the training process slower than standard methods.
  • DermaMNIST Performance: While Medi-CAT performed well, it remained second-best on the DermaMNIST dataset compared to the "Complex Mixer" model, suggesting there is still room to optimize for specific types of medical imagery.
  • Future Directions: The authors plan to extend this contrastive adversarial approach beyond simple classification to more complex tasks like medical object detection and image segmentation.

Summary updated

Abstract

There are not many large medical image datasets available. For these datasets, too small deep learning models can't learn useful features, so they don't work well due to underfitting, and too big models tend to overfit the limited data. As a result, there is a compromise between the two issues. This paper proposes a training strategy Medi-CAT to overcome the underfitting and overfitting phenomena in medical imaging datasets. Specifically, the proposed training methodology employs large pre-trained vision transformers to overcome underfitting and adversarial and contrastive learning techniques to prevent overfitting. The proposed method is trained and evaluated on four medical image classification datasets from the MedMNIST collection. Our experimental results indicate that the proposed approach improves the accuracy up to 2% on three benchmark datasets compared to well-known approaches, whereas it increases the performance up to 4.1% over the baseline methods.
BibTeX
@inproceedings{khan2024medi,
  author = {Pervaiz Iqbal Khan and Andreas Dengel and Sheraz Ahmed},
  title = {{Medi-CAT: Contrastive Adversarial Training for Medical Image Classification}},
  booktitle = {ICAART},
  year = {2024},
  doi = {10.5220/0012396500003636},
}
Figure