Introduction
Medical image interpretation is a high-stakes task traditionally performed by radiologists and clinicians. However, human analysis is prone to inter-observer variability, fatigue, and a non-negligible miss rate. While Convolutional Neural Networks (CNNs) have become the standard for automating this process, they possess an inherent inductive bias—they are excellent at picking up local patterns but can struggle to capture the global, long-range relationships within an image. This study investigates whether Transformer-based architectures, originally designed for natural language processing, can provide a more robust and efficient alternative for multi-class medical image classification across different anatomical regions.
Methods
The authors evaluated several variants of the Vision Transformer (ViT) and the Data-Efficient Image Transformer (DeiT). Unlike CNNs, which process images pixel-by-pixel through sliding filters, ViTs break an image into non-overlapping patches, project them into a linear embedding space, and use multi-head self-attention to allow every patch to interact with every other patch, capturing global context.
The researchers fine-tuned models pre-trained on ImageNet-21k (ViT-B/16, ViT-L/16, and ViT-L/32) and compared them against a suite of state-of-the-art CNNs, including DenseNet and InceptionResNetV2. To handle extreme class imbalance, they employed Focal Loss, which forces the model to focus on hard-to-classify samples rather than being overwhelmed by common "normal" cases.
Datasets
The study utilized three publicly available benchmarks to test the models' versatility:
- Chest X-ray Dataset: 7,135 images covering COVID-19, Normal, Pneumonia, and Tuberculosis.
- Kvasir Dataset: 8,000 endoscopic images across 8 classes including anatomical landmarks and pathologies like polyps.
- Kvasir-Capsule: A massive, heavily imbalanced dataset of 44,152 frames from video capsule endoscopy featuring 13 classes.
Key Results
The Vision Transformer models consistently outperformed CNNs across all modalities. For the Chest X-ray dataset, ViT-L/16 achieved a Matthews Correlation Coefficient (MCC) of 0.9259 and an F1-score of 0.9532, significantly surpassing the best CNN ensembles.
On the challenging Kvasir-Capsule dataset, ViT-B/16 achieved the highest MCC (0.3705), demonstrating a superior ability to identify rare pathologies compared to traditional architectures. Statistical tests confirmed these performance gains were significant (p < 0.05) for both the X-ray and Capsule datasets. Furthermore, ViTs were found to be up to four times more computationally efficient during training than equivalent CNNs.
Discussion and Conclusion
The primary advantage of ViTs in medical imaging lies in their self-attention mechanism, which learns intricate global patterns that CNNs might miss. This is particularly useful in X-rays, where the relationship between different lung zones is critical for diagnosis. While challenges like labeling noise and extreme class imbalance in capsule endoscopy remain, this work highlights the potential for Transformers to set new standards in clinical diagnostic support systems.
Summary updated