Few-Shot Cross-Dataset Adaptation for Tuberculosis Detection Using DenseNet
Organizations: Department of Computer Science and Engineering, Dhaka International University, Dhaka, Bangladesh.
Abstract
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.
Figures & tables
| Step 1: Initialize DenseNet-121 with pretrained weights from TBX11K |
| Step 2: Replace classifier with binary output layer |
| Step 3: Train model on source dataset (TBX11K) |
| For each shot size : |
| Sample labeled images per class from target dataset |
| If Frozen Backbone Adaptation: |
| Freeze feature extractor layers |
| Setting | Pretrained | Fine-Tuning Scope | Target Labels Used |
|---|---|---|---|
| Zero-shot | Yes | None | 0 |
| Frozen | Yes | Classifier only | per class |
| Full FT | Yes | All layers | per class |
| Scratch | No | All layers | per class |
| Shots per class | Frozen Backbone | Full Fine-tuning | Scratch |
|---|---|---|---|
| 10 | 75.07 | 88.86 | 93.88 |
| 25 | 77.89 | 98.21 | 94.76 |
| 50 | 88.86 | 99.45 | 92.81 |
| 75 | 88.56 | 98.36 | 97.55 |
| 100 | 90.78 | 99.68 | 91.13 |
| Metric | Value |
|---|---|
| Accuracy | 98.43% |
| Precision (TB) | 100.0% |
| Recall (TB) | 98.1% |
| F1-score (TB) | 99.05% |
| AUC | 99.99% |
Cross-Dataset Generalization
Cross-dataset generalization studies whether AI models retain accuracy, calibration, and usefulness on data from sources beyond their training set.
See all 142 papers