A Hybrid CNN-Transformer Framework for Automated Tuberculosis Detection from Chest X-rays
Main Article Content
Abstract
Tuberculosis (TB) remains a major global health challenge, demanding rapid and accurate diagnosis to enable timely treatment and reduce disease transmission. Although chest radiography is widely used for TB screening, manual interpretation is often time-consuming, subjective, and constrained by the shortage of experienced radiologists, especially in high-burden, resource-constrained settings. To address these limitations, this study proposes HybridTBNet, a hybrid deep learning framework that integrates Convolutional Neural Networks (CNNs) and Transformers for automated TB detection from chest X-ray images. The model is designed to capture both local pathological patterns and global contextual dependencies through hierarchical feature extraction and attention-based representation learning. A curated multi-source dataset of 6,708 high-quality chest X-ray images, comprising 3,194 TB and 3,514 Normal cases after quality filtering, was used for development and evaluation. A strict patient-wise split was applied to prevent data leakage, resulting in separate training, validation, and held-out test sets; however, minor class imbalance persisted in the final test subset. On the unseen test set, HybridTBNet achieved 98.2% accuracy, 97.1% sensitivity, 98.5% specificity, 94.9% F1-score, 0.991 ROC-AUC, and 0.978 PR-AUC, demonstrating strong potential as an effective automated TB screening support tool.
Article Details

This work is licensed under a Creative Commons Attribution 4.0 International License.
Journal of Studies in Science and Engineering is licensed under a Creative Commons Attribution License 4.0 (CC BY-4.0).
References
S. P. Althomsons et al., "Using machine learning techniques and national tuberculosis surveillance data to predict excess growth in genotyped tuberculosis clusters," American journal of epidemiology, vol. 191, no. 11, pp. 1936-1943, 2022, doi: https://doi.org/10.1093/aje/kwac117.
A. R. Bhardwaj, A. Pathak, S. Rajput, D. K. Singh, and N. Kashyap, "Tuberculosis prediction system using machine learning," in Computational Methods in Science and Technology. London: CRC Press, 2024, pp. 16-23, doi: https://doi.org/10.1201/9781003561651-3 .
E. Bustad et al., "Predicting fitness in Mycobacterium tuberculosis with transcriptional regulatory network-informed interpretable machine learning," Frontiers in Tuberculosis, vol. 3, p. 1500899, 2025, doi: https://doi.org/10.3389/ftubr.2025.1500899.
Y. Chen et al., "Advantages of updated WHO mutation catalog combined with existing whole-genome sequencing-based approaches for Mycobacterium tuberculosis resistance prediction," Genome Medicine, vol. 17, no. 1, p. 31, 2025, doi: https://doi.org/10.1186/s13073-025-01458-0.
W. Deelder, G. Napier, S. Campino, L. Palla, J. Phelan, and T. G. Clark, "A modified decision tree approach to improve the prediction and mutation discovery for drug resistance in Mycobacterium tuberculosis," BMC genomics, vol. 23, no. 1, p. 46, 2022, doi: https://doi.org/10.1186/s12864-022-08291-4.
S. Feng et al., "Prediction model for spinal cord injury in spinal tuberculosis patients using multiple machine learning algorithms: a multicentric study," Scientific Reports, vol. 14, no. 1, p. 7691, 2024, doi: https://doi.org/10.1038/s41598-024-56711-0.
H. W. Gichuhi, M. Magumba, M. Kumar, and R. W. Mayega, "A machine learning approach to explore individual risk factors for tuberculosis treatment non-adherence in Mukono district," PLOS global public health, vol. 3, no. 7, p. e0001466, 2023, doi: https://doi.org/10.1371/journal.pgph.0001466.
A. G. Green et al., "A convolutional neural network highlights mutations relevant to antimicrobial resistance in Mycobacterium tuberculosis," Nature communications, vol. 13, no. 1, p. 3817, 2022, doi: https://doi.org/10.1038/s41467-022-31236-0.
M. I. Gröschel et al., "GenTB: A user-friendly genome-based predictor for tuberculosis resistance powered by machine learning," Genome medicine, vol. 13, no. 1, p. 138, 2021, doi: https://doi.org/10.1186/s13073-021-00953-4.
R. Thirunavukarasu and E. Kotei, "A comprehensive review on transformer network for natural and medical image analysis," Computer Science Review, vol. 53, p. 100648, 2024, doi: https://doi.org/10.1016/j.cosrev.2024.100648.
E. Kotei and R. Thirunavukarasu, "Tuberculosis detection from chest X-ray image modalities based on transformer and convolutional neural network," IEEE Access, vol. 12, pp. 97417-97427, 2024, doi: https://doi.org/10.1109/ACCESS.2024.3428446.
M. Galvosas et al., "Differentiating Cough Origins in Non-Contact AI Monitoring: Analyzing'Non-User Coughs' with the Hyfe CoughMonitor Smartwatch," vol. 64, ed: European Respiratory Society, 2024, doi: https://doi.org/10.1183/13993003.congress-2024.PA789.
P. Karmani, A. A. Chandio, I. A. Korejo, O. W. Samuel, and M. Aborokbah, "Machine learning based tuberculosis (ML-TB) health predictor model: early TB health disease prediction with ML models for prevention in developing countries," PeerJ Computer Science, vol. 10, p. e2397, 2024, doi: https://doi.org/10.7717/peerj-cs.2397.
T. R. Lane et al., "Machine learning models for Mycobacterium tuberculosis in vitro activity: prediction and target visualization," Molecular pharmaceutics, vol. 19, no. 2, pp. 674-689, 2021, doi: https://doi.org/10.1021/acs.molpharmaceut.1c00791.
J. Larkins-Ford et al., "Systematic measurement of combination-drug landscapes to predict in vivo treatment outcomes for tuberculosis," Cell systems, vol. 12, no. 11, pp. 1046-1063. e7, 2021, doi: https://doi.org/10.1016/j.cels.2021.08.004.
Y. Li et al., "Machine learning and radiomics for the prediction of multidrug resistance in cavitary pulmonary tuberculosis: a multicentre study," European Radiology, vol. 33, no. 1, pp. 391-400, 2023, doi: https://doi.org/10.1007/s00330-022-08997-9.
J. Y. Maipan-Uku and N. Cavus, "Forecasting tuberculosis incidence: a review of time series and machine learning models for prediction and eradication strategies," International Journal of Environmental Health Research, vol. 35, no. 3, pp. 645-660, 2025, doi: https://doi.org/10.1080/09603123.2024.2368137.
H. M. KB, S. A. Jose, A. Jirawattanapanit, and K. Mathew, "A comprehensive study on tuberculosis prediction models: Integrating machine learning into epidemiological analysis," Journal of Theoretical Biology, vol. 597, p. 111988, 2025, doi: https://doi.org/10.1016/j.jtbi.2024.111988.
S. S. Murugesan, S. Velu, M. Golec, H. Wu, and S. S. Gill, "Neural networks based smart e-health application for the prediction of tuberculosis using serverless computing," IEEE Journal of Biomedical and Health Informatics, vol. 28, no. 9, pp. 5043-5054, 2024, doi: https://doi.org/10.1109/JBHI.2024.3367736.
A. D. Orjuela-Cañón, A. L. Jutinico, C. Awad, E. Vergara, and A. Palencia, "Machine learning in the loop for tuberculosis diagnosis support," Frontiers in Public Health, vol. 10, p. 876949, 2022, doi: https://doi.org/10.3389/fpubh.2022.876949.
J. Parmar, S. K. Patel, V. Katkar, and A. Natesan, "Graphene-based refractive index sensor using machine learning for detection of mycobacterium tuberculosis bacteria," IEEE Transactions on NanoBioscience, vol. 22, no. 1, pp. 92-98, 2022, doi: https://doi.org/10.1109/TNB.2022.3155264.
R. Perea-Jacobo, G. R. Paredes-Gutiérrez, M. Á. Guerrero-Chevannier, D.-L. Flores, and R. Muñiz-Salazar, "Machine learning of the whole genome sequence of Mycobacterium tuberculosis: a scoping PRISMA-based review," Microorganisms, vol. 11, no. 8, p. 1872, 2023, doi: https://doi.org/10.3390/microorganisms11081872.
M. Serajian, C. Testagrose, M. Prosperi, and C. Boucher, "A comparative study of antibiotic resistance patterns in Mycobacterium tuberculosis," Scientific reports, vol. 15, no. 1, p. 5104, 2025, doi: https://doi.org/10.1038/s41598-025-89087-w.
M. Singh et al., "Evolution of machine learning in tuberculosis diagnosis: a review of deep learning-based medical applications," Electronics, vol. 11, no. 17, p. 2634, 2022, doi: https://doi.org/10.3390/electronics11172634.
K. Stański, S. Lycett, T. Porphyre, and B. d. C. Bronsvoort, "Using machine learning improves predictions of herd-level bovine tuberculosis breakdowns in Great Britain," Scientific Reports, vol. 11, no. 1, p. 2208, 2021, doi: https://doi.org/10.1038/s41598-021-81716-4.
N. Tang et al., "Machine learning prediction model of tuberculosis incidence based on meteorological factors and air pollutants," International journal of environmental research and public health, vol. 20, no. 5, p. 3910, 2023, doi: https://doi.org/10.3390/ijerph20053910.
D. A. Winkler, "The impact of machine learning on future tuberculosis drug discovery," Expert Opinion on Drug Discovery, vol. 17, no. 9, pp. 925-927, 2022, doi: https://doi.org/10.1080/17460441.2022.2108785.
Y. Xu et al., "Machine learning-based prediction of antimicrobial resistance and identification of AMR-related SNPs in Mycobacterium tuberculosis," BMC Genomic Data, vol. 26, no. 1, p. 48, 2025, doi: https://doi.org/10.1186/s12863-025-01338-x.
Q. Ye et al., "Identification of active molecules against Mycobacterium tuberculosis through machine learning," Briefings in Bioinformatics, vol. 22, no. 5, p. bbab068, 2021, doi: https://doi.org/10.1093/bib/bbab068.
A. Yurtseven, S. Buyanova, A. A. Agrawal, O. O. Bochkareva, and O. V. Kalinina, "Machine learning and phylogenetic analysis allow for predicting antibiotic resistance in M. tuberculosis," BMC microbiology, vol. 23, no. 1, p. 404, 2023, doi: https://doi.org/10.1186/s12866-023-03147-7.
Y. Zeng et al., "Risk prediction of liver injury in pediatric tuberculosis treatment: development of an automated machine learning model," Drug Design, Development and Therapy, pp. 239-250, 2025, doi: https://doi.org/10.2147/DDDT.S495555.
A. Zhang, L. Teng, and G. Alterovitz, "An explainable machine learning platform for pyrazinamide resistance prediction and genetic feature identification of Mycobacterium tuberculosis," Journal of the American Medical Informatics Association, vol. 28, no. 3, pp. 533-540, 2021, doi: https://doi.org/10.1093/jamia/ocaa233.
J. Zhu et al., "Two-centers machine learning analysis for predicting acid-fast bacilli results in tuberculosis sputum tests," Journal of Clinical Tuberculosis and Other Mycobacterial Diseases, vol. 38, p. 100511, 2025, doi: https://doi.org/10.1016/j.jctube.2025.100511.
M. A. Shames and M. Y. Kamil, "Development and Validation of a Diagnosis System for Lung Infection Using Hybrid Deep-Learning Techniques," Journal of Studies in Science and Engineering, vol. 4, no. 1, pp. 61-74, 2024, doi: https://doi.org/10.53898/josse2024415.