Papers
Topics
Authors
Recent
Search
2000 character limit reached

CBAM-Enhanced DenseNet121 for Multi-Class Chest X-Ray Classification with Grad-CAM Explainability

Published 14 Apr 2026 in eess.IV and cs.CV | (2604.12305v1)

Abstract: Pneumonia remains a leading cause of childhood mortality worldwide, with a heavy burden in low-resource settings such as Bangladesh where radiologist availability is limited. Most existing deep learning approaches treat pneumonia detection as a binary problem, overlooking the clinically critical distinction between bacterial and viral aetiology. This paper proposes CBAM-DenseNet121, a transfer-learning framework that integrates the Convolutional Block Attention Module (CBAM) into DenseNet121 for three-class chest X-ray classification: Normal, Bacterial Pneumonia, and Viral Pneumonia. We also conduct a systematic binary-task baseline study revealing that EfficientNetB3 (73.88%) underperforms even the custom CNN baseline (78.53%) -- a practically important negative finding for medical imaging model selection. To ensure statistical reliability, all experiments were repeated three times with independent random seeds (42, 7, 123), and results are reported as mean +/- standard deviation. CBAM-DenseNet121 achieves 84.29% +/- 1.14% test accuracy with per-class AUC scores of 0.9565 +/- 0.0010, 0.9610 +/- 0.0014, and 0.9187 +/- 0.0037 for bacterial pneumonia, normal, and viral pneumonia respectively. Grad-CAM visualizations confirm that the model attends to anatomically plausible pulmonary regions for each class, supporting interpretable deployment in resource-constrained clinical environments.

Authors (1)

Summary

  • The paper introduces a CBAM-DenseNet121 model that integrates channel and spatial attention for reliable multi-class chest X-ray classification.
  • Key methodological enhancements include a two-phase training regimen and Grad-CAM visualizations ensuring interpretability and clinical plausibility.
  • Results demonstrate robust performance with 84.29% mean accuracy and high per-class AUCs, confirming its potential for resource-constrained settings.

CBAM-Enhanced DenseNet121 for Multi-Class Chest X-Ray Classification with Grad-CAM Explainability

Introduction

This paper addresses a clinically critical gap in deep learning-driven chest X-ray (CXR) diagnostics: the lack of robust multi-class frameworks that distinctly identify normal, bacterial pneumonia, and viral pneumonia cases. While prior approaches on datasets such as ChestX-ray14 and CheXpert primarily focus on binary classification, conflating bacterial and viral etiologies limits clinical utility and contributes to inappropriate antibiotic use. In settings like Bangladesh, where the scarcity of radiologists is acute, the delineation between these pneumonia subtypes is essential to enable proper triage and antibiotic stewardship. This work proposes an architecture—CBAM-DenseNet121—that leverages the Convolutional Block Attention Module (CBAM) integrated into a DenseNet121 backbone, providing channel and spatial attention enhancements. Model interpretability for deployment feasibility is addressed with Grad-CAM-based visual explanations.

Foundational literature such as CheXNet established DenseNet121 as a robust architecture for pneumonia detection. However, most studies emphasize binary classification. Attention mechanisms have shown significant promise in medical imaging tasks: Schlemper et al. used attention gates for localization, while CBAM, previously explored in retinal and dermatological applications, has not been systematically applied to multi-class pneumonia detection in chest X-rays until this work. Prior studies applying EfficientNet-family models in medical imaging do not adequately address sub-classification granularity or attention-driven interpretability. Additionally, Grad-CAM has emerged as a de facto standard for qualitative validation of CNN-based interpretability, yet without specific focus on actionable multi-class scenarios relevant to real-world pediatric pneumonia triage and management.

Dataset and Experimental Protocol

The experiments utilize the Kermany Chest X-Ray dataset, containing 5,863 images, with labels post-processed to form three classes: NORMAL, BACTERIAL PNEUMONIA, and VIRAL PNEUMONIA. The authors identify the inadequacy of the official validation set (16 samples) and implement an 80/20 stratified split, ensuring robust class coverage during validation and optimal generalization assessment. Balanced class weights correct for data imbalance, using inverse-frequency scaling applied during categorical cross-entropy loss computation.

Data augmentation for the training set incorporates random rotation, flipping, shifts, zoom, and intensity scaling, followed by normalization of all sets. The full test set remains completely unseen until final evaluation, mitigating risks of data leakage. Results are systematically reported as mean ± standard deviation across three random initializations (seeds 42, 7, 123), ensuring replicability.

Model Architecture and Training

CBAM is strategically embedded after the final DenseNet121 convolutional block, providing dual attention mechanisms: channel attention adjusts the importance of different feature maps, while spatial attention prioritizes pixel regions within those maps, yielding a refined and context-sensitive feature representation. The classifier head comprises global average pooling, batch normalization, two dense layers with interleaved dropout for regularization, and a three-unit softmax output.

A two-phase training regimen is executed:

  1. Phase 1: The entire DenseNet121 base is frozen; only CBAM and the classifier head are trained (15 epochs, Adam optimizer, higher learning rate).
  2. Phase 2: The last 30 DenseNet layers are unfrozen for selective fine-tuning (20 epochs, lower learning rate), with early stopping and adaptive learning rate scheduling.

Such incremental unfreezing and careful regularization mitigate catastrophic forgetting while extracting maximum utility from pretrained weights.

Comparative Baselines

Four baselines (custom 3-block CNN, ResNet50, EfficientNetB3, and vanilla DenseNet121) are benchmarked on a binary classification task for context. Notably, EfficientNetB3 yields lower accuracy (73.88%) than the basic baseline CNN (78.53%), highlighting that high-parameter or aggressively scaled architectures optimized for RGB natural images do not necessarily transfer effectively to grayscale, low-contrast radiography without domain-specific pretraining. DenseNet121 attains the strongest performance (91.03% accuracy, AUC = 0.9706), underscoring its suitability for the CXR domain.

Results

Three-class CBAM-DenseNet121 achieves:

  • Mean accuracy: 84.29%±1.14%84.29\% \pm 1.14\%
  • Macro-average AUC: 0.9454±0.00130.9454 \pm 0.0013
  • Per-class AUCs: Bacterial Pneumonia (0.9565±0.00100.9565 \pm 0.0010), Normal (0.9610±0.00140.9610 \pm 0.0014), Viral Pneumonia (0.9187±0.00370.9187 \pm 0.0037)

Standard deviation across seeds is low, underlining statistical robustness. The model demonstrates strong discriminative performance, particularly for bacterial cases (recall 0.94±0.000.94 \pm 0.00), with normal and viral pneumonia exhibiting some confusability, especially in mild and early viral presentations, which is consistent with radiological reality.

The primary confusion (misclassifying viral pneumonia as normal) reflects the known subtlety of viral radiographic patterns and indicates the upper-bound limitations imposed by visual features alone, rather than model inductive bias or overfitting.

Grad-CAM Visualizations

Grad-CAM overlays demonstrate that CBAM-DenseNet121 consistently attends to radiologically and anatomically plausible regions: lobar consolidation for bacterial pneumonia, distributed mediastinal focus for normal, and peripheral/interstitial activation for viral pneumonia. This alignment with expert-derived anatomical priors is central to trustworthiness for clinical deployment. The transparency provided by Grad-CAM is crucial for both regulatory review and radiologist workflow integration, providing visual rationale rather than opaque predictions.

Discussion

The integration of CBAM into DenseNet121 improves per-class discriminability on the more clinically relevant three-class task, moving beyond binary detection paradigms. Importantly, the negative finding regarding EfficientNetB3’s inferiority to a simplistic CNN baseline signals the necessity of rigorous empirical validation and domain-aware model selection for clinical AI workflows; parameter count and literature popularity do not guarantee transfer performance.

The practical value is significant in resource-constrained health systems: the model is lightweight enough for standard GPU deployment, precludes the need for specialized imaging infrastructure, and provides interpretable outputs. This de-risks implementation in environments lacking radiology subspecialists and supports integration with telemedicine or edge-based diagnostic aid.

Limitations and Future Work

The Kermany dataset’s single-institution origin and the label derivation via filename parsing are notable sources of demographic and label noise. Broader generalizability will require testing on multi-institution datasets such as CheXpert and ChestX-ray14. The study’s statistical repeatability (triplicate runs) is robust for the field, though future iterations should formally compare against radiologist-annotated ROIs for quantitative validation of Grad-CAM’s anatomical fidelity and explore model compression for edge deployment scenarios.

Prospective clinical trials, especially in LMIC settings, and external validation against gold-standard datasets are prerequisite for real-world translation. This analytic pipeline can serve as a template for extending attention-based explainable classification to other image-driven multi-class tasks in medical imaging.

Conclusion

CBAM-DenseNet121 defines a replicable, attention-augmented framework for three-class pneumonia classification, attaining clinically actionable performance and producing anatomically corroborated explanations. The empirical finding that EfficientNetB3 is suboptimal for CXR underscores the necessity for careful architecture selection and domain adaptation in medical imaging AI. The approach lays the foundation for further research into explainable, trustworthy, and robust AI systems for radiographic triage, especially in resource-limited settings, with clear avenues for improvement in dataset diversity, label fidelity, and cross-domain validation.

Reference: "CBAM-Enhanced DenseNet121 for Multi-Class Chest X-Ray Classification with Grad-CAM Explainability" (2604.12305).

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.