Abstract
Convolutional Neural Networks (CNNs) have reigned for a decade as the de facto approach to automated medical image diagnosis. Recently, vision transformers (ViTs) have appeared as a competitive alternative to CNNs, yielding similar levels of performance while possessing several interesting properties that could prove beneficial for medical imaging tasks. In this work, we explore whether it is time to move to transformer-based models or if we should keep working with CNNs—can we trivially switch to transformers? If so, what are the advantages and drawbacks of switching to ViTs for medical image diagnosis? We consider these questions in a series of experiments on three mainstream medical image datasets. Our findings show that, while CNNs perform better when trained from scratch, off-the-shelf vision transformers using default hyperparameters are on par with CNNs when pretrained on ImageNet, and outperform their CNN counterparts when pretrained using self-supervision.
Introduction
For the last decade, Convolutional Neural Networks (CNNs) have been the undisputed kings of medical imaging. However, the rise of Vision Transformers (ViTs) in the natural image domain has sparked a debate: can we switch? The primary barrier is data scarcity. ViTs lack the "inductive biases" of CNNs—the hard-coded assumptions that pixels near each other are related—which usually means they require massive datasets to learn effectively. Medical datasets are notoriously small and often have noisy labels. This study investigates whether a typical practitioner with a limited budget and standard medical datasets can successfully transition to ViTs without losing performance.
Methods
The authors conducted a head-to-head comparison between a representative CNN (ResNet50) and a comparable ViT (DeiT-S), matched by parameter count and compute requirements. They evaluated three initialization strategies:
- Random Initialization: Training from scratch.
- Supervised Transfer Learning: Initializing with weights pre-trained on ImageNet.
- Self-Supervised Pre-training (SSL): Using the DINO (Self-distillation with no labels) method on the target medical data after ImageNet initialization, followed by supervised fine-tuning.
The models were tested on three datasets: APTOS 2019 (retinal images), ISIC 2019 (skin lesions), and CBIS-DDSM (mammography).
Quantitative Performance
The results demonstrate that while CNNs outperform ViTs when trained from scratch (due to the inductive bias gap), pre-training acts as a "great equalizer." With ImageNet pre-training, the performance gap disappears. Furthermore, ViTs show a slight but consistent edge over CNNs when self-supervised pre-training (DINO) is applied to the medical data.
As shown in Table 1, DeiT-S achieved a 0.896 Kappa on APTOS (vs. 0.893 for ResNet) and 0.844 Recall on ISIC (vs. 0.810 for ResNet) with supervised pre-training. The addition of self-supervision further boosted ViT performance on ISIC to 0.853 Recall, outperforming the CNN counterpart.
Interpretability and Qualitative Analysis
Beyond raw metrics, ViTs offer superior, high-resolution interpretability through their built-in attention mechanisms. Unlike CNN saliency methods (like Grad-CAM), which produce coarse, "blobby" heatmaps, ViT attention maps provide sharp, localized visualizations of specific pathologies.
The qualitative analysis highlights that ViTs naturally focus on the boundaries of skin lesions and specific exudates in retinal images, providing a level of granularity that is difficult to achieve with standard CNNs. This "free" interpretability is a significant advantage for clinical applications where understanding the model's reasoning is crucial.
Conclusion
If practitioners are already using ImageNet pre-training, there is no longer a performance penalty for switching to Transformers. In fact, the combination of competitive performance, synergy with self-supervised learning, and superior interpretability makes ViTs a compelling "plug-and-play" alternative for medical image diagnosis. While ViTs are more sensitive to hyperparameters, their ability to provide high-resolution clinical insights makes them a strong candidate for the next generation of medical AI.
Summary updated