Journal Article

·2025

A Hybrid CNN–Transformer Domain-Adversarial Neural Network for Robust Pneumonia Classification in Heterogeneous Chest X-Ray Datasets

Fatma Betul Akyol YTU , Gökhan Bilgin YTU

Abstract

The generalizable detection of pneumonia from chest X-ray (CXR) images remains a significant challenge due to inherent domain shift between diverse imaging datasets. While advanced deep learning models show promise, their generalization across varying imaging protocols, equipment, and patient groups is often limited. This study initially explored a Multi-task Domain-Adversarial Neural Network (DANN) framework with a monolithic Swin Transformer backbone, which, despite its classification potential, exhibited challenges in effectively mitigating domain shift, showing increased divergence metrics post-adaptation. To overcome this, we propose and investigate a novel DANN framework featuring a hybrid backbone combining ResNet and Transformer Encoder layers. This hybrid approach leverages the strengths of Convolutional Neural Networks (CNNs) for robust local feature extraction and Transformers for comprehensive global context understanding. It simultaneously performs multi-label pathology classification (NIH ChestX-ray14) and binary pneumonia detection (Chest X-Ray Images (Pneumonia)), while achieving explicit adversarial feature alignment. Our comparative analysis demonstrates that the proposed hybrid approach not only achieved superior pneumonia detection performance (Accuracy: 0.921, AUC: 0.974, F1-score: 0.939) but also successfully reduced domain shift, as evidenced by significant reductions in FID (from 143.61 to 15.66), CORAL (from 1324.26 to 85.67), and KL divergence (from 1149.71 to 914.62) post-adaptation. This contrasts sharply with the monolithic Swin backbone, which struggled to reduce these divergence metrics. This work highlights the effectiveness of complex hybrid architectures in enabling robust feature alignment and generalization for complex medical imaging tasks under domain shift.

Keywords

Convolutional neural network Feature extraction Deep learning Binary classification Pattern recognition (psychology) Encoder Artificial neural network Generalization Transformer Computer science Artificial intelligence

Subject Areas

COVID-19 diagnosis using AI ·Radiology, Nuclear Medicine and Imaging ·Health Sciences