Your new experience awaits. Try the new design now and help us make it even better

ORIGINAL RESEARCH article

Front. Med.

Sec. Precision Medicine

Secure Pulmonary Diagnosis using Transformer-Based Approach to X-Ray Classification with KL Divergence Optimization

Provisionally accepted
  • 1Akal University, Bathinda, India
  • 2Jazan University, Jizan, Saudi Arabia
  • 3King Fahd University of Petroleum & Minerals, Dhahran, Saudi Arabia
  • 4University of the West of Scotland, Paisley, United Kingdom

The final, formatted version of the article will be published soon.

Lung disease classification plays a significant part in the early discovery and diagnosis of respiratory conditions. This paper proposes a novel approach for lung disease classification utilizing two advanced deep learning models, MedViT and Swin Transformer. The models are evaluated on the Lung X-Ray Image Dataset that includes 10,425 X-ray images categorized into three classes: Normal with 3,750 images, Lung Opacity with 3,375 images, and Viral Pneumonia with 3,300 images. A series of data augmentation methods, including geometric and photometric augmentation, are combined to improve model performance and generalisation. The results illustrate that both MedViT and Swin Transformer accomplish promising classification accuracy. MedViT showing particular strength in medical image-specific feature learning due to its hybrid convolutional and transformer design. The impact of different loss functions is also examined, where Kullback–Leibler Divergence yields the highest accuracy and effectively handles class imbalance. The best-performing MedViT model achieves an accuracy of 98.6% with a test loss of 0.09, highlighting its potential for reliable clinical decision support. Whereas, the Swin Transformer model achieved 0.92 accuracy and 0.16 test loss.

Keywords: Pulmonary disease classification, Secure Medical Diagnostics, Lung disease classification, deep learning, Chest X-ray analysis, Medical image augmentation

Received: 30 Sep 2025; Accepted: 26 Nov 2025.

Copyright: © 2025 Anand, Shuaib, Khan, Ullah and Alam. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) or licensor are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.

* Correspondence: Mehran Ullah

Disclaimer: All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.