Source-linked AI summary

Few-Shot Cross-Dataset Adaptation for Tuberculosis Detection Using DenseNet

Bidhan Biswas, Shahadat Hossain Sohag, Nabil Ashab, Soumit Kumar Kundu, Saif Mahmud Parvez

arXiv:2608.21427v1cs.CV

TL;DR

Domain shift causes tuberculosis detection models trained on TBX11K to lose performance on the Mendeley TB dataset. This paper evaluates few-shot target adaptation and finds that full fine-tuning achieves strong performance with limited labeled data, reaching 98.36% accuracy with 75 samples per class.

  • Problem

    Domain shift across datasets, driven by differing imaging characteristics, patient groups, and machines, can significantly reduce tuberculosis detection performance on a new dataset.

  • Method

    The study evaluates few-shot adaptation from TBX11K to Mendeley TB using a pretrained model fine-tuned on a small labeled target subset instead of retraining from scratch.

  • Results

    98.36% accuracy is achieved with 75 labeled samples per class, while full fine-tuning outperforms frozen-backbone adaptation and correctly identifies all 430 normal cases.

  • Takeaways & Limitations

    Pretraining on TBX11K followed by fine-tuning with a few labeled target-domain samples is presented as a practical strategy for clinical deployment.

  • Takeaways & Limitations

    Calibration metrics such as calibration error and Brier score, along with additional validation and statistical significance tests, are not included.

Abstract

from arXiv · show

Tuberculosis (TB) is one of the most common and dangerous bacterial ailments. Every year, it causes a large number of deaths worldwide. Although many deep learning models can detect tuberculosis from chest X-rays quite accurately, severe domain shift across datasets makes the task challenging. Different imaging protocols, patient demographics, and equipment across domains make the task of generalization difficult. In real-world settings, a model may perform well on one dataset but show a noticeable drop in performance when tested on another. In this work, we address this domain adaptation challenge through a few-shot scaling study. A controlled cross-dataset evaluation is presented in this paper using TBX11K as the source domain and the Mendeley TB dataset as the target domain. It is investigated how varying the number of target samples affects model performance under three training regimes: frozen backbone adaptation, full fine-tuning of a source-pretrained DenseNet121 model, and training from scratch. The results indicate that the model can perform well even with limited data and can achieve 98.36\% accuracy with just 75 labeled samples per class. The adaptation curves demonstrate how fine-tuning effectively mitigates domain shift. These findings establish full fine-tuning of pretrained models as a highly effective and practical strategy for mitigating domain shift in low-resource clinical deployment scenarios.

1 Introduction

Chest-X-ray TB detection performs well within datasets but faces domain shift across clinical settings. This work evaluates few-shot adaptation and reports improved performance as labeled target data increases.

  • Motivation: Domain shift causes models trained on one dataset to lose accuracy when applied to another clinical domain.Differences across datasets make generalization difficult in everyday clinical practice.
  • Study focus: The evaluation compares frozen-backbone adaptation, full fine-tuning, and training from scratch.These training regimes are used to examine how adaptation choices affect cross-dataset performance.
  • Study focus: Few-shot adaptation improves performance as labeled target data increases from 1% to 15% of the target dataset.The study examines adaptation under progressively larger labeled target subsets.
  • Evaluation: Performance is evaluated using accuracy, precision, recall, F1-score, and AUC.The evaluation uses multiple classification metrics rather than accuracy alone.
  • Contribution: The study presents few-shot learning as an effective way to work across different clinical settings.The contribution focuses on adapting models with limited labeled target-domain data.

2 Related Work

Prior TB imaging studies often evaluate models on the same datasets used for training, while domain shift and limited labeled data remain important challenges. This work addresses that gap through few-shot cross-dataset adaptation.

  • Related work: Most prior TB detection models are trained and tested on the same datasets.This limits direct evidence about generalization across domains.
  • Existing approaches: Researchers have explored ensembles, uncertainty estimation, multi-disease classification, augmentation, oversampling, and domain-adaptation methods.These approaches target performance, uncertainty, class imbalance, or cross-domain generalization.
  • Existing approaches: Few-shot learning has been studied because collecting large labeled datasets is often infeasible.Related approaches include orthogonal softmax layers, hybrid efficient models, and EfficientNet-based methods.
  • Study positioning: This study uses TBX11K as a large source dataset and Mendeley as a smaller target dataset collected from a different hospital.The datasets provide a cross-dataset setting for evaluating adaptation.
  • Study positioning: Unlike zero-shot or fully supervised target training, the work evaluates promising performance using only a small number of labeled target samples.The comparison motivates few-shot adaptation as an intermediate supervision setting.

3 Datasets

The study uses TBX11K for source training and Mendeley TB for target adaptation and evaluation. Their different sources and image characteristics create a realistic domain-shift setting.

  • Datasets: The study uses two public tuberculosis chest-X-ray datasets: TBX11K and Mendeley TB.Both datasets are described as having many samples and high-quality annotations.
  • TBX11K: TBX11K contains about 11,200 annotated chest X-ray images collected from multiple sources.It includes classification and localization annotations, but this study uses only classification labels.
  • TBX11K: Active and latent TB are grouped as the positive class, while healthy and non-TB cases form the negative class.This binary grouping supports the study’s classification task.
  • Mendeley TB: Mendeley contains 2,494 tuberculosis-patient X-rays and 514 normal X-rays from a local hospital in Pakistan.It serves as the target dataset after source training on TBX11K.
  • Evaluation protocol: Training images are separated from evaluation images, with few-shot samples selected per class and the remainder reserved for evaluation.The protocol reduces the risk of unintended data leakage in cross-dataset testing.
  • Domain shift: The datasets differ in contrast, brightness, and noise levels, making the domain shift challenging and realistic.Both datasets were classified and verified by expert radiologists.

4 Methodology

The methodology frames cross-dataset TB detection as a domain-adaptation problem and fine-tunes a source-pretrained DenseNet-121 with limited target data. The model uses dense feature reuse and a binary TB classifier.

  • 4.1 Problem Definition: Domain shift is defined as a performance drop when a TB model trained on TBX11K is applied to Mendeley TB.Differences in imaging characteristics, patient groups, and machines contribute to the drop.
  • 4.1 Problem Definition: The goal is to reduce this drop by fine-tuning a pretrained model with a small labeled subset of the target dataset.The approach targets adaptation without requiring full target-domain supervision.
  • 4.2 Backbone Architecture: DenseNet-121 is selected because dense connectivity supports feature reuse and stable gradient flow in medical-image analysis.The architecture is intended to identify texture and shadowing differences effectively.
  • 4.2 Backbone Architecture: The pretrained fully connected layer is replaced with a single-node classifier that outputs the probability of TB presence.The classifier produces a binary disease-presence prediction.
  • 4.2 Backbone Architecture: The source model minimizes empirical cross-entropy risk, but performance degrades on the target dataset because source and target joint distributions differ.The target dataset is Mendeley TB, and the source dataset is TBX11K.
  • 4.2 Backbone Architecture: Few-shot adaptation fine-tunes the pretrained model using a target subset containing k% of the target samples.The adaptation objective is defined over the selected labeled target subset.

4.3 Training Strategy

The study evaluates zero-shot transfer, frozen-backbone adaptation, full fine-tuning, and training from scratch for cross-dataset TB detection. Models use target samples per class under a standardized training and augmentation setup.

  • Preprocessing: Input preprocessing resizes images to 224×224 pixels and applies ImageNet normalization.Training augmentation includes horizontal flipping, rotation, and intensity variation.
  • Optimization: Models are trained with Adam or AdamW and Binary Cross-Entropy loss.The experiments are implemented in PyTorch.
  • Experimental control: Experiments use 10 epochs for few-shot training and 5 epochs for adaptation, with a fixed random seed of 42.The fixed seed is used to ensure consistent results.
  • Training regimes: Four regimes compare direct source-to-target transfer, frozen-backbone adaptation, full fine-tuning, and training from scratch.The adaptation settings use k labeled samples per class, while zero-shot transfer uses no target adaptation.
  • Target sampling: Few-shot adaptation samples k labeled images per class from the target dataset.The supplied training settings define k as the number of labeled target images used per class.

4.6 Algorithm Description

The adaptation algorithm initializes DenseNet-121 with TBX11K-pretrained weights, replaces its classifier, and evaluates alternative adaptation regimes across target-data shot sizes. The study addresses domain variation, limited labels, overfitting risk, and class imbalance in clinical deployment.

  • Algorithm: DenseNet-121 is initialized with TBX11K-pretrained weights and given a binary output classifier.The procedure then samples target-domain labels for each shot size.
  • Algorithm: For each k ∈ {10, 25, 50, 75, 100}, the algorithm samples k labeled images per class from the target dataset.The supplied algorithm description presents these as the evaluated shot sizes.
  • Clinical setting: The targeted deployment challenges include differing imaging characteristics, patient demographics, equipment, limited labels, overfitting with small k, and class imbalance.The paper frames these challenges as common in real-world clinical deployment scenarios.

5 Results

Results show that zero-shot transfer performs poorly across clinical settings, while full fine-tuning improves fastest as target shots increase and reaches the highest performance. At the 15% adaptation split, the model achieves 98.43% accuracy with few errors, and its heatmaps emphasize clinically relevant lung regions.

  • 5.1 Few-Shot Scaling Behavior: Zero-shot transfer does not perform well when applied to different clinical settings.This result reflects the cross-dataset performance challenge evaluated in the study.
  • 5.1 Few-Shot Scaling Behavior: Full fine-tuning shows the fastest improvement and reaches the highest performance level with a few labeled samples.Frozen-backbone adaptation improves more slowly as additional target samples are added.
  • 5.2 Confusion Matrix: 98.43% overall model accuracy is achieved on the Mendeley test set using the 15% target adaptation split.The model correctly identifies all 430 normal cases and 2,087 of 2,127 TB cases.
  • 5.3 Describing the model with Grad-CAM: Grad-CAM highlights background lung tissue for a normal case and central lung abnormalities for a TB case.These visualizations are described as aligning with radiological expectations and indicating attention to meaningful diagnostic features.
  • 5.2 Confusion Matrix: The full fine-tune confusion matrix contains very few mistakes overall, especially for TB cases.The caption specifies that the matrix is evaluated on the Mendeley test set with the 15% adaptation split.
  • 5.4 Scaling Interpretation: The adaptation curve flattens after 50 shots, indicating performance near supervised training.Here, k denotes the number of labeled samples per class.

6 Discussion

Discussion of the cross-dataset study indicates that full fine-tuning adapts DenseNet-121 most effectively, while frozen or scratch training are less reliable under domain shift.

  • The Grad-CAM heatmaps highlight background lung tissue for normal images and central lung abnormalities for TB images.These regions are described as clinically relevant areas of model attention.
  • The frozen backbone cannot adjust effectively to the Mendeley domain shift.It provides only modest improvement through TBX11K feature extraction.
  • Full fine-tuning reaches the highest performance level with few labeled target samples.Its performance curve steps above the frozen-backbone curve.
  • 98.36% accuracy is achieved with 75 labeled samples per class through full fine-tuning.
  • At the 15% adaptation split, the model correctly identifies all 430 normal cases and 2,087 of 2,127 TB cases, reaching 98.43% accuracy.The analysis reports approximately 40 missed TB cases and emphasizes the screening relevance of false-negative performance.
  • Zero-shot transfer performs poorly in another domain, whereas full fine-tuning achieves excellent performance with limited data.

7 Future Work

Future work proposes broader validation, improved reliability assessment, more efficient adaptation, and extension to additional diseases and architectures.

  • Calibration metrics such as calibration error and Brier score should be added because the study reports AUC, recall, and F1-score without them.
  • Additional validation techniques and statistical significance tests are identified as future additions.
  • Parameter-efficient methods such as adapters or LoRA could reduce computational cost when labeled data are limited.
  • Testing on other public datasets would clarify how well the model generalizes.
  • Future studies could compare transformer-based architectures with DenseNet-121 and extend classification to Pneumonia and COVID-19.

8 Conclusion

The study examines DenseNet-121 transfer from TBX11K to Mendeley under domain shift and applies few-shot fine-tuning to the target domain. With 75 labeled samples per class, it reports up to 98.36% accuracy and clinically relevant Grad-CAM attention.

  • DenseNet-121 performs well on TBX11K but degrades when applied to the Mendeley dataset.
  • Few-shot fine-tuning on the target dataset achieves up to 98.36% accuracy with 75 labeled samples per class.
  • Grad-CAM heatmaps indicate that the model learns clinically relevant features.
Loading 2608.21427v1…