CLARiTy: A Vision Transformer for Multi-Label Classification and Weakly-Supervised Localization of Chest X-ray Pathologies
Organizations: School of Computer Science and Applied Mathematics, University of the Witwatersrand, Johannesburg, South Africa
Abstract
The interpretation of chest X-rays poses significant challenges in achieving accurate multi-label pathology classification and spatial localization. These tasks demand different annotation granularities but are constrained by the scarcity of region-level (dense) annotations. We introduce CLARiTy (Class Localizing and Attention Refining Image Transformer), a vision transformer-based model for joint multi-label classification and weakly-supervised localization of thoracic pathologies. CLARiTy employs multiple class-specific tokens to generate discriminative attention maps and a SegmentCAM module for foreground segmentation and background suppression using explicit anatomical priors. Trained on image-level labels from the NIH ChestXray14 dataset, it leverages distillation from a ConvNeXtV2 teacher for efficiency. Localization heatmaps are converted to bounding boxes with OneBox, a hysteresis-gated extractor whose parameters are calibrated per finding on held-out validation data. Evaluated on the official NIH split, CLARiTy achieves competitive classification across 14 pathologies and strong weakly-supervised localization on 8 pathologies, outperforming prior methods by up to 50.7% relative Macro Intersection over Union (IoU) Accuracy at stringent thresholds. Gains are most pronounced for small pathologies: at T(IoU) = 0.5, the 224 variant reaches an IoU Accuracy of 0.154 on nodules, where the compared methods remain at or below 0.013. The lower-resolution CLARiTy-S-16-224 offers high efficiency while surpassing baselines, and could potentially be applied in low-resource settings. An ablation study confirms the contributions of SegmentCAM, DINO pretraining, and attention pooling. CLARiTy advances beyond CNN-ViT hybrids by harnessing ViT self-attention for global context and class-specific localization, refined through convolutional background suppression for precise, noise-reduced heatmaps.
Figures & tables
| Pathology | Anatomical Regions |
| Atelectasis | Left Lung, Right Lung |
| Cardiomegaly | Heart |
| Consolidation | Left Lung, Right Lung |
| Edema | Left Lung, Right Lung |
| Effusion | Left Lung, Right Lung |
| Emphysema | Left Lung, Right Lung |
| Loss Weight | Value |
| 2.2674 | |
| 2.4678 | |
| 3.9670 | |
| 0.4377 | |
| 0.1427 |
| Model | Image Size | NIH Training Set Size | Macro AUC | Macro IoU Accuracy at T(IoU) | ||||
| 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | ||||
| RGT 1 ‡ | 224 | 70% | † | 0.591 | 0.424 | 0.281 | 0.173 | 0.090 |
| ThoraX-PriorNet-224 2 ‡ | 224 | 70% | 0.666 | 0.509 | 0.398 | 0.296 | 0.201 | |
| ThoraX-PriorNet-512 2 ‡ | 512 | 70% | 0.847 | 0.803 | 0.626 | 0.488 | 0.334 | 0.217 |
| Wang et al. (2024) ‡ | 224 | – | – | 0.450 | – | 0.230 | – | – |
| Wang et al. (2017) | 1024 | 70% | 0.568 | 0.373 | 0.221 | 0.116 | 0.062 | |
| Model | Pathology AUC | ||||||||||||||
| Atel. | Card. | Cons. | Edem. | Effu. | Emph. | Fibr. | Hern. | Infi. | Mass | Nodu. | Pleu. | Pn. 1 | Pn. 2 | Mean | |
| Yao et al. (2017) ‡ | |||||||||||||||
| Li et al. (2018) ‡ | |||||||||||||||
| Ho and Gwak (2019) ‡ | |||||||||||||||
| Ho and Gwak (2019) ¶ | |||||||||||||||
| RGT 1 ‡ | † | † | – | – | † | – | – | – | † | † | † | – | † | † | † |
| T(IoU) | Model | Pathology IoU Accuracy | ||||||||
| Atel. | Card. | Effu. | Infi. | Mass | Nodu. | Pn. 1 | Pn. 2 | Mean | ||
| 0.1 | RGT 1 ‡ | |||||||||
| ThoraX-PriorNet-224 2 ‡ | 1.000 | |||||||||
| ThoraX-PriorNet-512 2 ‡ | 1.000 | 0.763 | ||||||||
| Wang et al. (2024) ‡ | ||||||||||
| [1pt/1.5pt] | Wang et al. (2017) | |||||||||
| SegmentCAM | Dice | Pretrained Weights | Classification Loss | Class Token Pooling | Validation Metric | |||||
| ImageNet | DINO | MLSM | WBCE | GAP | Attention | Macro AUC | MSLI | UDP | ||
| ✓ | ✓ | – | ✓ | – | ✓ | – | ✓ | 0.836 | 0.391 | 0.614 |
| – | – | – | ✓ | – | ✓ | – | ✓ | 0.841 | 0.339 | 0.590 |
| ✓ | – | – | ✓ | – | ✓ | – | ✓ | 0.833 | 0.302 | 0.567 |
| ✓ | ✓ | ✓ | – | – | ✓ | – | ✓ | 0.826 | 0.363 | 0.595 |
| ✓ | ✓ | – | ✓ | ✓ | – | – | ✓ | 0.841 | 0.382 | 0.611 |
| Image Size | Component | Parameters | FLOPS |
| 224 | Vision Transformer Backbone | 21.68 M | 4.95 G |
| Attention Pooling Module | 5.38 K | 5.38 K | |
| SegmentCAM Module | 2.94 M | 0.87 G | |
| CLARiTy-S-16-224 | 24.62 M | 5.83 G | |
| 512 | Vision Transformer Backbone | 21.99 M | 32.41 G |
| Attention Pooling Module | 5.38 K | 5.38 K |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| GT box area | Instances | 224 | 512 |
| 36 | 0.056 | 0.167 | |
| – | 38 | 0.053 | 0.105 |
| – | 75 | 0.173 | 0.173 |
| – | 108 | 0.157 | 0.111 |
| – | 87 | 0.287 | 0.195 |
| 149 | 0.638 | 0.644 |
| Finding | Instances | Accuracy | Missed (small/mirr.) | Extra boxes |
| Atelectasis | 91 | 0.121 | 80 (12/2) | 1.58 |
| Cardiomegaly | 73 | 1.000 | 0 (0/0) | 0.00 |
| Effusion | 77 | 0.078 | 71 (7/4) | 1.77 |
| Infiltration | 62 | 0.274 | 45 (2/2) | 1.35 |
| Mass | 43 | 0.326 | 29 (10/0) | 1.09 |
| Nodule | 39 | 0.154 | 33 (31/0) | 1.79 |
| Group | Images | 224 | 512 |
| All | 25,595 | 0.808 | 0.825 |
| Male | 14,881 | 0.809 | 0.825 |
| Female | 10,714 | 0.806 | 0.824 |
| PA view | 11,096 | 0.803 | 0.822 |
| AP view | 14,499 | 0.786 | 0.803 |
| Age | 8,411 | 0.749 | 0.770 |
| Finding | |||||
| Atelectasis | 0.00 | 0.75 | 0.80 | 0.25 | 1.10 |
| Cardiomegaly | 4.00 | 0.05 | 0.40 | 1.25 | 1.00 |
| Effusion | 0.00 | 0.70 | 0.75 | 1.00 | 1.10 |
| Infiltration | 2.00 | 0.65 | 0.80 | 0.50 | 1.10 |
| Mass | 1.00 | 0.70 | 0.75 | 0.50 | 1.10 |
| Nodule | 2.00 | 0.75 | 0.80 | 0.75 | 0.90 |
| Macro IoU Accuracy at T(IoU) | ||||||||
| Model | Extractor | Boxes/inst | [email protected] | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 |
| CLARiTy-S-16-224 | Wang | 3.89 | 3.55 | 0.830 | 0.730 | 0.590 | 0.424 | 0.302 |
| OneBox | 1.60 | 1.29 | 0.780 | 0.667 | 0.529 | 0.401 | 0.303 | |
| Wang, top-2 | 2.00 | 1.71 | 0.672 | 0.582 | 0.467 | 0.353 | 0.255 | |
| OneBox, top-2 | 1.52 | 1.21 | 0.768 | 0.658 | 0.521 | 0.397 | 0.298 | |
| Wang, top-1 | 1.00 | 0.84 | 0.507 | 0.375 | 0.252 | 0.200 | 0.144 | |
| Metric | 95% CI | ||
| Macro AUC | +0.0169 | [0.015, 0.019] | < 0.0005 |
| IoU Acc. @0.1 | +0.0422 | [0.009, 0.077] | 0.0130 |
| IoU Acc. @0.2 | +0.0294 | [-0.007, 0.066] | 0.1170 |
| IoU Acc. @0.3 | +0.0273 | [-0.011, 0.067] | 0.1720 |
| IoU Acc. @0.4 | +0.0219 | [-0.018, 0.061] | 0.2700 |
| IoU Acc. @0.5 | -0.0034 | [-0.037, 0.029] | 0.8430 |
| CLARiTy-S-16-224 | CLARiTy-S-16-512 | |
| 0.1 | 0.780 [0.745, 0.814] | 0.822 [0.789, 0.854] |
| 0.2 | 0.667 [0.631, 0.705] | 0.698 [0.662, 0.733] |
| 0.3 | 0.529 [0.491, 0.568] | 0.552 [0.516, 0.596] |
| 0.4 | 0.401 [0.365, 0.436] | 0.419 [0.384, 0.459] |
| 0.5 | 0.303 [0.271, 0.333] | 0.295 [0.263, 0.331] |
| Pathology | CLARiTy-S-16-224 | CLARiTy-S-16-512 | ConvNeXtV2-B-224 | ConvNeXtV2-B-512 |
| Atelectasis | 0.765 [0.757, 0.773] | 0.791 [0.783, 0.798] | 0.772 [0.764, 0.780] | 0.787 [0.779, 0.794] |
| Cardiomegaly | 0.902 [0.894, 0.909] | 0.902 [0.894, 0.909] | 0.892 [0.884, 0.900] | 0.898 [0.890, 0.905] |
| Consolidation | 0.760 [0.751, 0.770] | 0.764 [0.754, 0.773] | 0.750 [0.740, 0.759] | 0.758 [0.749, 0.767] |
| Edema | 0.852 [0.843, 0.861] | 0.856 [0.847, 0.864] | 0.853 [0.844, 0.861] | 0.855 [0.846, 0.863] |
| Effusion | 0.833 [0.827, 0.839] | 0.837 [0.831, 0.843] | 0.828 [0.822, 0.834] | 0.832 [0.826, 0.837] |
| Emphysema | 0.895 [0.885, 0.904] | 0.936 [0.929, 0.942] | 0.900 [0.891, 0.909] | 0.938 [0.931, 0.944] |
Chest X-Ray Classification
Chest X-ray classification uses machine learning to detect and categorize diseases and findings in radiographs for screening, triage, and clinical decision support.
See all 101 papers