Hyperparameter Optimized DenseNet201 for Chest X-Ray Pneumonia and Tuberculosis Classification with Grad-CAM Visualization

Authors

  • Damianus Christopher Samosir Informatics Engineering, Faculty of Engineering, Universitas Bengkulu, Bengkulu, Indonesia
  • Ernawati Informatics Engineering, Faculty of Engineering, Universitas Bengkulu, Bengkulu, Indonesia
  • Desi Andreswari Informatics Engineering, Faculty of Engineering, Universitas Bengkulu, Bengkulu, Indonesia

DOI:

https://doi.org/10.34148/teknika.v15i3.1533

Keywords:

DenseNet201, Transfer Learning, Pneumonia, Tuberculosis, Grad-CAM

Abstract

Pneumonia and tuberculosis (TB) remain major global health challenges, particularly in developing countries. Chest X-ray imaging is the most commonly used initial diagnostic modality, yet visual similarity between these diseases and normal lung conditions frequently causes diagnostic ambiguity. Deep learning, particularly through transfer learning with DenseNet201, offers promising potential for automated multi-class classification; however, numerically high accuracy alone does not guarantee training stability, generalization robustness, or clinical reliability. This study investigates hyperparameter optimization of DenseNet201 transfer learning for three-class chest X-ray classification (Normal, Pneumonia, and Tuberculosis), systematically evaluating the interaction between learning rates (LR) (1 × 10⁻⁵, 5 × 10⁻⁶, 1 × 10⁻⁶), batch sizes (BS) (8, 16, 32), and fine-tuning strategies (full fine-tuning, partial freeze 10%, and partial freeze 20%). Training was conducted across two phases, namely feature extraction and fine-tuning, yielding 27 experimental scenarios. The optimal configuration, consisting of full fine-tuning, batch size 8, and learning rate 1 × 10⁻⁵, achieved a test accuracy of 98.06%, a macro F1-score of 0.981, and a macro ROC-AUC of 0.999. Despite these results, an error analysis revealed that 27 of 1,392 test images were misclassified, with 19 disease cases incorrectly predicted as Normal, highlighting that distinguishing subtle pathological patterns from Normal chest X-rays remains a key challenge. Furthermore, Grad-CAM visualization showed class-specific activation patterns, including central activation for Normal, diffuse bilateral activation for Pneumonia, and apical activation for Tuberculosis, providing visual insights into the image regions contributing to the model’s classification decisions.

Downloads

Download data is not yet available.

References

[1] A. Badu-Peprah, Y. D. Appiah, J. B. Babatunde, Z. Alebache, S. J. Badu-Peprah, and F. Quarshie, “Abnormal chest X-ray findings of patients with confirmed tuberculosis in Ghana,” Cureus, vol. 17, no. 6, Art. no. e86359, 2025, doi: 10.7759/cureus.86359.

[2] Forum of International Respiratory Societies, “Pneumonia Remains a Leading Cause of Child Mortality,” FIRS Official Website. [Online]. Available: https://firsnet.org/on-world-pneumonia-day-experts-demand-action-to-save-children

[3] World Health Organization, “Tuberculosis resurges as top infectious disease killer,” World Health Organization. [Online]. Available: https://www.who.int/news/item/29-10-2024-tuberculosis-resurges-as-top-infectious-disease-killer

[4] K. K. R. Indonesia, “Indonesia’s movement to end TB.” [Online]. Available: https://kemkes.go.id/eng/indonesias-movement-to-end-tb

[5] T. Rahman et al., “Reliable Tuberculosis Detection using Chest X-ray with Deep Learning, Segmentation and Visualization,” IEEE Access, vol. 8, pp. 191586–191601, 2020.

[6] D. W. Feyisa, Y. M. Ayano, and T. G. Debelee, “Weak localization of radiographic manifestations in pulmonary tuberculosis from chest X-ray: A systematic review,” Sensors, vol. 23, no. 15, Art. no. 6781, 2023, doi: 10.3390/s23156781.

[7] M. A. Elemraid et al., “Accuracy of the interpretation of chest radiographs for the diagnosis of paediatric pneumonia,” PLoS ONE, vol. 9, no. 8, Art. no. e106051, 2014, doi: 10.1371/journal.pone.0106051.

[8] S. Bennani et al., “Using AI to improve radiologist performance in detection of abnormalities on chest radiographs,” Radiology, vol. 309, no. 3, Art. no. e230860, 2023, doi: 10.1148/radiol.230860.

[9] M. Bhandari, T. B. Shahi, B. Siku, and A. Neupane, “Explanatory classification of CXR images into COVID-19, pneumonia and tuberculosis using deep learning and XAI,” Computers in Biology and Medicine, vol. 150, Art. no. 106156, 2022, doi: 10.1016/j.compbiomed.2022.106156.

[10] S. Dardouri, “A deep convolutional neural network model for lung disease detection using chest X-ray imaging,” Pulmonary Medicine, vol. 2025, Art. no. 6614016, 2025, doi: 10.1155/pm/6614016.

[11] R. Jha, V. Bhattacharjee, and A. Mustafi, “Transfer Learning with Feature Extraction Modules for Improved Classifier Performance on Medical Image Data,” Sci. Program., vol. 2022, 2022, doi: 10.1155/2022/4983174.

[12] A. Davila, J. Colan, and Y. Hasegawa, “Comparison of fine-tuning strategies for transfer learning in medical image classification,” Image and Vision Computing, vol. 146, Art. no. 105012, 2024, doi: 10.1016/j.imavis.2024.105012.

[13] G. Huang and K. Q. Weinberger, “Densely Connected Convolutional Networks,” Proc. IEEE Conf. Comput. Vis. Pattern Recognit., 2017.

[14] K. Srilatha and E. Saikiran, “Advanced skin cancer detection: A deep learning and transfer learning framework for melanoma classification,” Journal of Information Systems Engineering and Management, vol. 10, no. 23s, pp. 140–154, 2025, doi: 10.52783/jisem.v10i23s.3687.

[15] H. Malik, T. Anees, M. Din, and A. Naeem, “CDC_Net: Multi-classification convolutional neural network model for detection of COVID-19, pneumothorax, pneumonia, lung cancer, and tuberculosis using chest X-rays,” Multimedia Tools and Applications, vol. 82, no. 9, pp. 13855–13880, 2023, doi: 10.1007/s11042-022-13843-7.

[16] N. Bhushan, S. Mekhilef, K. S. Tey, M. Shaaban, and M. Seyedmahmoudian, “Dynamic K-Decay Learning Rate Optimization for Deep Convolutional Neural Network to Estimate the State of Charge,” Energies, vol. 17, no. 16, Art. no. 3884, 2024, doi: 10.3390/en17163884.

[17] R. Bumbálek, T. Zoubek, J. de Dieu, M. Ufitikirezi, S. N. Umurungi, and R. Stehlík, “Implementation of Machine Vision Methods for Cattle Detection and Activity Monitoring,” Technologies, vol. 13, no. 3, Art. no. 116, 2025, doi: 10.3390/technologies13030116.

[18] W. Samek and K.-R. Müller, “Towards Explainable Artificial Intelligence,” in Explainable AI: Interpreting, Explaining and Visualizing Deep Learning, vol. 11700, Springer, 2019, pp. 5–22, doi: 10.1007/978-3-030-28954-6_1.

[19] I. E. Ihongbe, S. Fouad, T. F. Mahmoud, A. Rajasekaran, and B. Bhatia, “Evaluating explainable artificial intelligence (XAI) techniques in chest radiology imaging through a human-centered lens,” PLoS ONE, vol. 19, no. 10, Art. no. e0308758, 2024, doi: 10.1371/journal.pone.0308758.

[20] A. Hazlett, N. Ohashi, T. Rodriguez, and S. Adewole, “Chest disease detection in X-ray images using deep learning classification method,” arXiv preprint arXiv:2505.22609, 2025.

[21] T. Zhou, X. Y. Ye, H. L. Lu, X. Zheng, S. Qiu, and Y. Liu, “Dense convolutional network and its application in medical image analysis,” BioMed Research International, vol. 2022, Art. no. 2384830, 2022, doi: 10.1155/2022/2384830.

[22] P.-H. Huynh and T.-D. Truong, “Dynamic fine-tuning strategy of deep learning models for lung disease classification on chest X-ray images,” Journal of Electronics, Electromedical Engineering, and Medical Informatics, vol. 8, no. 3, pp. 1047–1059, 2026, doi: 10.35882/jeeemi.v8i3.1352.

[23] C. Coil and N. Cheney, “What makes freezing layers in deep neural networks effective? A linear separability perspective,” in Proc. Fourth Int. Conf. Automated Mach. Learn., Proc. Mach. Learn. Res., vol. 293, pp. 9/1–32, 2025.

[24] I. Kandel and M. Castelli, “The effect of batch size on the generalizability of the convolutional neural networks on a histopathology dataset,” ICT Express, vol. 6, no. 4, pp. 312–315, 2020, doi: 10.1016/j.icte.2020.04.010.

[25] S. Lee, C. He, and S. Avestimehr, “Achieving small-batch accuracy with large-batch scalability via Hessian-aware learning rate adjustment,” Neural Networks, vol. 158, pp. 1–14, 2023, doi: 10.1016/j.neunet.2022.11.007.

[26] I. A. Usmani, M. T. Qadri, R. Zia, F. S. Alrayes, and O. Saidani, “Interactive effect of learning rate and batch size to implement transfer learning for brain tumor classification,” Electronics, vol. 12, no. 4, Art. no. 964, 2023, doi: 10.3390/electronics12040964.

[27] A. Sharifnassab, S. Salehkaleybar, and R. S. Sutton, “MetaOptimize: A framework for optimizing step sizes and other meta-parameters,” in Proc. 42nd Int. Conf. Mach. Learn., Proc. Mach. Learn. Res., vol. 267, pp. 54300–54325, 2025.

[28] C. Gu and M. Lee, “Deep transfer learning using real-world image features for medical image classification, with a case study on pneumonia X-ray images,” Bioengineering, vol. 11, no. 4, Art. no. 406, 2024, doi: 10.3390/bioengineering11040406.

[29] Z. Fu, A. M.-C. So, and N. Collier, “A stability analysis of fine-tuning a pre-trained model,” arXiv preprint arXiv:2301.09820, 2023, doi: 10.48550/arXiv.2301.09820.

[30] N. Alsubaie, T. Alqahtani, and S. B. Rahayu, “Lung-centric feature analysis for accurate pneumonia detection in chest X-ray images,” in Computer Science & Information Technology (CS & IT), D. C. Wyld et al., Eds., AIRCC Publishing Corporation, 2024, pp. 129–143, doi: 10.5121/csit.2024.140108.

[31] S. Kiziloluk, E. Sert, M. Hammad, R. Tadeusiewicz, and P. Pławiak, “EO-CNN: Equilibrium optimization-based hyperparameter tuning for enhanced pneumonia and COVID-19 detection using AlexNet and DarkNet19,” Biocybernetics and Biomedical Engineering, vol. 44, no. 3, pp. 635–650, 2024, doi: 10.1016/j.bbe.2024.06.006.

[32] R. Wajgi, G. Yenurkar, V. O. Nyangaresi, and S. Mallewar, “Optimized tuberculosis classification system for chest X-ray images: Fusing hyperparameter tuning with transfer learning approaches,” Engineering Reports, vol. 6, no. 11, Art. no. e12906, 2024, doi: 10.1002/eng2.12906.

[33] Y. Pamungkas, S. I. Sabilla, P. N. Crisnapati, Y. Gao, and Y. Thwe, “A comparative study of respiratory diseases classification using Grad-CAM-based DenseNet architectures,” International Journal of Robotics and Control Systems, vol. 6, no. 1, pp. 454–474, 2026, doi: 10.31763/ijrcs.v6i1.2164.

[34] S. K. Behera, K. Murali Gopal, and S. B. Punuri, “A deep learning-based pneumonia detection system with explainable AI for medical decision support,” in Proc. 2025 11th Int. Conf. Commun. Signal Process. (ICCSP), IEEE, 2025, pp. 694–699, doi: 10.1109/ICCSP64183.2025.11089357.

Hyperparameter Optimized DenseNet201 for Chest X-Ray Pneumonia and Tuberculosis Classification with Grad-CAM Visualization

Downloads

Published

2026-11-24

How to Cite

Hyperparameter Optimized DenseNet201 for Chest X-Ray Pneumonia and Tuberculosis Classification with Grad-CAM Visualization. (2026). Teknika, 15(3), 421-431. https://doi.org/10.34148/teknika.v15i3.1533