The problem
Tuberculosis remains one of the world's deadliest infectious diseases, and chest X-ray screening is a frontline triage tool in high-burden regions — but there are far fewer trained radiologists than X-ray machines. Computer-aided screening that flags TB-suggestive patterns (infiltrates, cavities, upper-lobe consolidation) can help prioritize which films a radiologist reads first. This project builds that screening idea as an honest educational prototype: a custom CNN trained from scratch on the two classic public TB X-ray collections from the U.S. National Library of Medicine, evaluated with ROC-AUC, sensitivity and specificity rather than a single accuracy number. The interactive demo lets you select real sample radiographs, run the analysis, and inspect where the network attended — while every page of the project states plainly that this is a teaching build, not a diagnostic device.
How it works
- The Montgomery (138) and Shenzhen (662) chest X-ray sets are combined — 800 frontal CXRs labeled normal vs TB — resized to 224×224 grayscale, histogram-equalized and normalized.
- Stratified train/validation/test splits preserve the class ratio; augmentation (small rotations, flips, contrast jitter) is applied during training.
- The custom CNN — 4 conv blocks → global average pooling → Dense(128, dropout 0.5) → sigmoid — is compiled with Adam (lr 1e-4) and weighted binary cross-entropy to handle class imbalance.
- Training runs with early stopping on validation AUC; the best checkpoint is kept and the curves recorded.
- The held-out test set is evaluated once: ROC-AUC, sensitivity, specificity and the confusion matrix are generated for the report.
- In the web demo, a selected radiograph is preprocessed identically and passed through the saved weights; the app shows probability bars and the attention overlay. All outputs are labeled illustrative — not a diagnosis.
Tech stack:
- Python 3, TensorFlow/Keras
- NumPy, Matplotlib, scikit-learn (metrics, ROC)
- Jupyter Notebook (training & evaluation)
- HTML5 + JavaScript (interactive radiograph demo)
- Montgomery + Shenzhen TB X-ray datasets (NLM, 800 CXRs)
Dataset & model details
- Dataset: Montgomery County X-ray Set (U.S. National Library of Medicine) — 138 frontal chest X-rays (80 normal, 58 TB); Shenzhen Hospital X-ray Set (U.S. National Library of Medicine) — 662 frontal chest X-rays (326 normal, 336 TB). Combined: 800 CXRs, binary labels (normal / TB).
- Task: Binary image classification; input = 224×224×1 grayscale radiograph, output = probability of TB-suggestive pattern.
- Model: Custom CNN (~2.1M parameters, design target): 4× (Conv 3×3 → BatchNorm → ReLU → MaxPool) with 32/64/128/256 filters → global average pooling → Dense 128 (dropout 0.5) → sigmoid. Weighted binary cross-entropy, Adam (lr 1e-4), early stopping on validation AUC.
- Metrics: Validation ROC-AUC ≈ 0.90, sensitivity ≈ 0.85, specificity ≈ 0.88 (design targets for the built-to-order training run), confusion matrix, PR curve. No figure is claimed as measured until the training run is executed for the order.
| Parameter | Value |
|---|---|
| Input format | 224 × 224 grayscale radiograph, histogram-equalized, normalized [0, 1] |
| Classes | 2 (normal/clear / TB-suggestive) |
| Training images | 800 frontal CXRs (Montgomery 138 + Shenzhen 662) |
| Model parameters | Approximately 2.1M (design target) |
| Validation ROC-AUC | ≈ 0.90 (design target, not a measured claim) |
| Sensitivity / specificity | ≈ 0.85 / 0.88 (design targets, not measured claims) |
| Inference | Approximately 15 ms per radiograph on CPU (expected) |
| Demo | Single-file web app, runs offline after download |
Project features
- [Custom CNN for radiographs] Four convolution blocks (32/64/128/256 filters) with batch normalization and max-pooling on 224×224 grayscale input, global average pooling, Dense(128) with dropout 0.5 and sigmoid output — ~2.1M parameters, designed from scratch with a documented rationale.
- [Interactive radiograph analysis] Select from 5 real sample chest X-rays, run the CNN analysis, and see TB-suggestive vs normal/clear probability bars with an explanatory note per image.
- [Grad-CAM-style attention overlay] A schematic heatmap marks the lung zones the model weighted most for the selected scan — the standard explainability visual for medical imaging, labeled as illustrative in the demo.
- [Real public TB X-ray collections] Trained on the Montgomery County (138 CXRs) and Shenzhen Hospital (662 CXRs) sets from the U.S. National Library of Medicine — real, citable, public data.
- [Clinically honest evaluation] ROC-AUC, sensitivity, specificity and confusion matrix instead of a lone accuracy figure, with the class imbalance handled by weighted loss — the way medical imaging is actually evaluated.
- [Full training notebook] Preprocessing (histogram equalization, normalization), augmentation, model definition, training with early stopping on validation AUC, and evaluation in one reproducible notebook.
- [Training curves] Validation AUC and loss curves across epochs with interpretation notes, included in the report.
- [Exported trained model] Saved weights plus the preprocessing pipeline so the demo runs the real network without retraining.
What is included
- Complete training & evaluation Jupyter notebook
- Trained CNN weights with preprocessing code
- Interactive radiograph-analysis web demo with attention overlay
- ROC/PR curves, confusion matrix and training-curve plots
- Project report PDF (background, CNN theory, architecture rationale, methodology, results, medical-AI limits)
- PPT presentation for final review
- Viva Q&A preparation document (CNNs, class imbalance, AUC vs accuracy, Grad-CAM, why this is not a diagnostic device)
Limitations & prerequisites
- An educational screening prototype — not a medical diagnostic device; no clinical claim is made and it must never guide patient care.
- 800 images is small for deep learning; the report discusses overfitting risk and the augmentation/regularization used to manage it.
- Frontal (PA/AP) views only — lateral views and CT are out of scope.
- TB labels in the public sets are image-level; the model does not localize lesions or distinguish active from latent TB.
- All performance figures are design targets for the training run, stated honestly — the report documents the actual achieved figures after training.
Frequently Asked Questions
Which datasets are used?
The two standard public TB X-ray collections from the U.S. National Library of Medicine: Montgomery County (138 CXRs: 80 normal, 58 TB) and Shenzhen Hospital (662 CXRs: 326 normal, 336 TB) — 800 frontal radiographs in total, both widely cited in TB-AI literature.
Why not just report accuracy?
Medical screening is evaluated on the trade-off between catching cases (sensitivity) and avoiding false alarms (specificity), summarized by ROC-AUC. A single accuracy number hides that trade-off, so the project reports AUC, sensitivity, specificity and the confusion matrix.
How does the attention overlay work?
The demo shows a Grad-CAM-style schematic heatmap over the lung fields marking the zones the model weighted most for its score. In the demo it is illustrative of the output format; the shipped build generates the real heatmap from the trained network.
Can this be used to diagnose TB?
No — and the project states this on every page. It is an educational prototype on public teaching images. Real diagnostic use requires regulated software, far larger curated datasets, and clinical validation, all explicitly out of scope.
What does the report cover?
TB screening background, the two NLM datasets, CNN architecture rationale, handling of class imbalance, training methodology, evaluation with ROC analysis, the attention visualization, limitations, and future scope.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It covers real medical-imaging data, honest evaluation methodology, explainability, and the ethics of medical AI, which makes for a strong, defensible viva. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.
Components & software requirements
- Python 3, TensorFlow/Keras
- NumPy, Matplotlib, scikit-learn (metrics, ROC)
- Jupyter Notebook (training & evaluation)
- HTML5 + JavaScript (interactive radiograph demo)
- Montgomery + Shenzhen TB X-ray datasets (NLM, 800 CXRs)
Dataset & model details
- Dataset: Montgomery County X-ray Set (U.S. National Library of Medicine) — 138 frontal chest X-rays (80 normal, 58 TB); Shenzhen Hospital X-ray Set (U.S. National Library of Medicine) — 662 frontal chest X-rays (326 normal, 336 TB). Combined: 800 CXRs, binary labels (normal / TB).
- Task: Binary image classification; input = 224×224×1 grayscale radiograph, output = probability of TB-suggestive pattern.
- Model: Custom CNN (~2.1M parameters, design target): 4× (Conv 3×3 → BatchNorm → ReLU → MaxPool) with 32/64/128/256 filters → global average pooling → Dense 128 (dropout 0.5) → sigmoid. Weighted binary cross-entropy, Adam (lr 1e-4), early stopping on validation AUC.
- Metrics: Validation ROC-AUC ≈ 0.90, sensitivity ≈ 0.85, specificity ≈ 0.88 (design targets for the built-to-order training run), confusion matrix, PR curve. No figure is claimed as measured until the training run is executed for the order.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.