A computational study evaluated a deep learning framework designed to automate the identification of Mycobacterium tuberculosis bacilli in sputum smear microscopy images and classify infection severity according to established clinical guidelines. Tuberculosis remains an infectious bacterial disease primarily affecting the lungs and is among the leading global causes of mortality, particularly in low- and middle-income nations. Prompt diagnosis is vital for infection control and initiating therapy, with sputum smear microscopy serving as an inexpensive, widely utilized visual diagnostic test in resource-limited clinical settings. Detecting bacilli manually under a microscope is labor-intensive and susceptible to subjective variability, especially when dealing with tiny rod-like bacteria distributed irregularly or in clusters across complex smear backgrounds. To address these operational constraints, the researchers integrated a Real-Time Detection Transformer architecture paired with an EfficientNet-B0 convolutional backbone, coupling the localization model with a rule-based bacillary counting algorithm and Gradient-weighted Class Activation Mapping to provide explainable diagnostic interpretations.
Traditional image processing techniques, such as Scale Invariant Feature Transform, Support Vector Machines, and Histogram of Oriented Gradients, have historically exhibited high sensitivity to variations in illumination, staining protocols, and image scaling. While conventional convolutional neural networks and prior object detection architectures like Faster R-CNN, Single Shot MultiBox Detector, and various iterations of YOLO have achieved automated bacilli localization, convolutional backbones typically rely on localized feature extraction. This restricted receptive field can hinder a model’s capacity to discriminate minute, low-contrast bacilli from visually similar mucinous debris and staining artifacts. Transformer-based object detection frameworks mitigate these limitations by establishing global contextual relationships across an entire image frame through attention mechanisms. By implementing the Real-Time Detection Transformer framework, known as RT-DETR, the investigators sought to capture both fine-grained morphological details and global context without relying on predefined anchor configurations, maintaining high detection accuracy while sustaining the throughput necessary for practical diagnostic environments.
The detection pipeline initiates by standardizing input sputum smear images, which originally possess varying dimensions, into a uniform resolution of 640 by 640 pixels across three color channels. Because microscopic sputum preparations frequently contain high-frequency noise and speckle artifacts, the images are preprocessed using a two-dimensional Gaussian filter. This convolution step applies a Gaussian kernel where central pixels receive greater weighting than peripheral pixels, smoothing extraneous background noise while preserving the structural edges and morphological integrity of the bacilli. Following noise reduction, data augmentation was applied to expand dataset diversity and prevent overfitting during neural network training. These transformations included horizontal flipping along the vertical axis, vertical flipping along the horizontal axis, and 270-degree rotational shifts. Applying these geometric augmentations systematically expanded an initial set of 1,265 raw sputum images into an augmented corpus of 5,060 training images, exposing the detector to diverse region-of-interest orientations.
The underlying neural architecture feeds the preprocessed input into the Mobile Inverted Convolution layers of an EfficientNet-B0 backbone, producing multiscale feature representations across descending spatial resolutions. These feature maps are subsequently processed by an RT-DETR hybrid encoder comprising an Axial Interaction and Fusion Interface and a Cross-Scale Collaborative Fusion module. The Axial Interaction block computes spatial attention independently along horizontal and vertical axes to enrich both local and global contextual representations without incurring prohibitive computational overhead. The Cross-Scale Collaborative Fusion module then merges spatial information across disparate resolution scales using learnable weights, positional encodings, and projection functions. The resulting fused representation passes through an Intersection over Union-aware query selection module, which nominates the 300 most informative object-aware queries. Within the transformer decoder, these selected queries undergo multi-head self-attention to capture mutual relationships before interacting with the refined encoder feature maps via cross-attention, ultimately generating bounding box coordinates and class probabilities passing a confidence threshold of 0.25.
To evaluate the system under rigorous conditions and minimize performance bias, the investigators implemented a three-fold cross-dataset validation strategy across three distinct public repositories: the TB Phone Camera dataset comprising 1,265 smartphone-captured microscopy images, the Mosaic dataset containing 3,000 microscopic mosaic patches, and the ZN dataset consisting of 35 Ziehl-Neelsen-stained images categorized by high or low background complexity and bacilli density. In the first cross-validation fold, the network was trained on the TB Phone Camera and ZN datasets and evaluated on the unseen Mosaic dataset. The second fold trained on TB Phone Camera and Mosaic images while testing on the ZN dataset, and the third fold utilized Mosaic and ZN images for training while assessing performance on the TB Phone Camera images. Patient-wise separation was strictly maintained during experimental splits to prevent data leakage between training and testing subsets, ensuring that individual patient samples never appeared simultaneously in both partitions.
The cross-dataset evaluation demonstrated consistent detection performance across varying imaging devices, staining techniques, and background conditions. Across ten independent trials, the model achieved mean precision values of 78.8 percent in Fold 1, 88.8 percent in Fold 2, and 90.3 percent in Fold 3, yielding an overall average precision of 86.0 percent. The corresponding recall metrics reached 82.9 percent, 93.4 percent, and 96.1 percent across the three folds, resulting in a mean recall of 90.8 percent. For mean average precision evaluated at an Intersection over Union threshold of 0.50, the model achieved 85.6 percent in Fold 1, 96.2 percent in Fold 2, and 97.2 percent in Fold 3, producing an aggregate mean of 93.0 percent. When measured across the stricter threshold range from 0.50 to 0.95, the average detection performance was 64.9 percent. An ablation study performed on the TB Phone Camera dataset indicated that substituting a standard backbone with EfficientNet-B0 increased mean average precision from 84.6 percent to 87.8 percent, adding the axial interface raised it to 90.1 percent, and incorporating the collaborative fusion module culminated in a peak detection score of 92.5 percent with 84.8 percent recall and 82.8 percent precision.
Computational efficiency assessments revealed that the entire processing pipeline—spanning initial Gaussian filtering, neural network inference, and post-processing bounding box generation—required an average of 10.7 milliseconds per image. This latency corresponds to an effective operational throughput of approximately 93 frames per second, confirming that the lightweight EfficientNet-B0 and transformer configuration operates within real-time parameters. To make the model’s diagnostic conclusions interpretable to clinicians, the researchers implemented Gradient-weighted Class Activation Mapping. Visual inspection of these activation heatmaps revealed dense, concentrated activations localized specifically over the morphological boundaries of the detected bacilli, consistently aligning with detection confidence scores exceeding 0.99. These visualizations verified that the network focused on biologically relevant bacterial structures rather than spurious staining artifacts or background glass imperfections.
In addition to object localization, the investigators formulated a rule-based severity grading algorithm modeled on International Union Against Tuberculosis and Lung Disease and World Health Organization guidelines. Under these criteria, disease severity is stratified based on the total number of visible bacilli identified across examined microscopic fields of view. The automated algorithm sequentially inspects image fields from a target specimen, detecting and tabulating individual bacilli while tracking the total fields reviewed. If at least 20 fields are checked and the average count exceeds 10 bacilli per field, the sample is classified as TB 3+, indicating heavy bacillary density and extreme severity. If between 1 and 10 bacilli are observed per field across 50 or more fields, the system assigns a TB 2+ grade, representing moderate infection. If a cumulative total exceeding 30 bacilli is identified across the full examination protocol of 300 fields without meeting earlier thresholds, the case is categorized as TB 1+, denoting low bacillary load.
Automated severity grading was empirically validated on the independent MIDTI-TB dataset, which contains digitized whole-slide microscopy images capturing 300 fields of view across 72 subjects. Applying the automated counting algorithm to the detector’s predictions achieved an overall severity classification accuracy of 94.45 percent, an aggregate precision of 97 percent, a recall of 94 percent, and an F1-score of 95.45 percent. Class-specific performance analysis demonstrated robust discrimination for extreme infection states: the system correctly identified 59 of 62 confirmed TB 3+ cases and misclassified only a single TB 1+ sample. Receiver operating characteristic curves confirmed near-perfect separability for the TB 1+ and TB 3+ categories. However, performance was comparatively constrained within the moderate TB 2+ cohort, which exhibited a class recall of 1.00 but an associated precision of 0.50 and an F1-score of 0.67, indicating that samples from adjacent severity categories were occasionally misassigned to this intermediate grade.
The authors identified several methodological and practical limitations that contextualize these experimental findings. The reduced classification precision observed for the TB 2+ category was partially attributed to the limited representation of intermediate cases within the MIDTI repository, where overlapping bacillary counts near categorical boundaries posed classification challenges. Furthermore, variations in optical illumination, staining intensity, contrast, and focal quality inherent to smartphone-mounted microscope adapters can influence bacilli morphology, complicating localization when bacteria appear faintly stained or densely clustered against complex mucus backgrounds. The researchers also cautioned that comparative literature benchmarks must be interpreted carefully, as prior studies operated under differing dataset splits, annotation conventions, and evaluation protocols. Finally, the authors noted that this study represented a computational evaluation utilizing secondary open-access data; prospective clinical trials, decision curve analyses, and formal validation by expert microbiologists and pathologists remain necessary before implementing such automated pipelines in primary healthcare facilities.
Subject of Research: Automated tuberculosis bacilli detection and severity grading using real-time detection transformers and explainable artificial intelligence
Article Title: EfficientNet-based detection transformer with explainable AI for tuberculosis bacilli detection and severity grading
Article References: Satapathy, A., Livingston, L. M. J., Rajkumar, S., Vallabhaneni, P., Indugula, M., & Leni, J. F. (2026). EfficientNet-based detection transformer with explainable AI for tuberculosis bacilli detection and severity grading. Informatics in Medicine Unlocked, 66, Article 101820. https://doi.org/10.1016/j.imu.2026.101820
Image Credits: AI Generated
DOI: 10.1016/j.imu.2026.101820
Keywords: tuberculosis, Mycobacterium tuberculosis, RT-DETR, EfficientNet-B0, sputum smear microscopy, severity grading, IUATLD criteria, computer-aided diagnosis, deep learning, object detection, Grad-CAM, explainable AI, MIDTI dataset, TB Phone Camera dataset, ZN dataset, Mosaic dataset
News Source: Ophelia Keating. (November 23, 2026). Real-Time Detection Transformer Accurately Identifies Tuberculosis Bacilli and Grades Disease Severity. Scienmag.



