Built to order

Pneumonia Detection using Transfer Learning

A chest X-ray classifier that scores a radiograph for lung opacity consistent with pneumonia. It fine-tunes a ResNet50 backbone (ImageNet pre-training) on the RSNA Pneumonia Detection Challenge data and overlays a Grad-CAM heatmap showing which lung regions drove the decision. The demo provides a case gallery, an inference panel and an explanation explorer. All metrics come from the training notebook run in the build. This is a research prototype, not a medical device. Suitable for B.E./B.Tech final-year projects in Computer Science, AI/ML and Biomedical streams.

Pneumonia Detection using Transfer Learning — project thumbnail preview
More project photos (2)

The problem

Pneumonia remains a leading infectious cause of death, and the chest X-ray is the most common study ordered for suspected cases. In high-burden settings the films pile up faster than radiologists can read them, and subtle opacities get missed when readers are fatigued. Automated assistance is a natural fit, but training a deep network from scratch on radiographs would need enormous labeled data. Transfer learning solves the data problem: a ResNet50 already trained on ImageNet has learned general visual structure, so fine-tuning its top layers on chest X-rays converges with tens of thousands of labeled films instead of millions. This project builds that pipeline end to end on the RSNA Pneumonia Detection Challenge set (26,684 frontal chest X-rays from the NIH Clinical Center, labeled Normal / No Lung Opacity-Not Normal / Lung Opacity), with Grad-CAM explanations so every prediction can be visually audited. The result is an assistive, explainable classifier whose limits are documented honestly, including the fact that it is an academic prototype and never a diagnostic device.

How it works

  1. Chest X-ray images are loaded from DICOM, resized to 224x224 and contrast-enhanced with CLAHE to make lung detail consistent across scanners.
  2. The dataset is split at the patient level so no patient's films appear in both training and validation.
  3. A ResNet50 backbone initialized with ImageNet weights has its classifier head replaced with a 3-way output; the head trains first while the backbone stays frozen.
  4. The top residual blocks are then unfrozen at a reduced learning rate for fine-tuning, with augmentation (rotation, flip, brightness) applied on the fly.
  5. Each epoch logs training/validation loss and accuracy; the best checkpoint on validation is kept and exported.
  6. At inference, the model returns class probabilities; Grad-CAM backpropagates the predicted class score to the last convolutional feature maps and overlays the resulting heatmap on the radiograph.
  7. The demo app serves this pipeline behind a case gallery and explanation explorer for live demonstration.

Tech stack:

  • Python 3.10, PyTorch with torchvision ResNet50
  • OpenCV, pydicom (DICOM decoding), NumPy, pandas
  • scikit-learn (patient-level splits, metrics)
  • Matplotlib, Seaborn (training curves, confusion matrix, ROC)
  • Flask demo app (case gallery, inference panel, Grad-CAM viewer)
  • RSNA Pneumonia Detection Challenge dataset (26,684 frontal chest X-rays, NIH Clinical Center)
Parameter Value
Model ResNet50 (ImageNet backbone), fine-tuned head + top residual blocks
Task 3-class classification: Normal / No Lung Opacity-Not Normal / Lung Opacity
Input Frontal chest X-ray, DICOM or PNG, resized 224x224
Preprocessing CLAHE contrast enhancement, ImageNet normalization, patient-level splits
Augmentation Rotation ±10°, horizontal flip, brightness jitter
Output Class probabilities + Grad-CAM attention heatmap
Evaluation Accuracy, confusion matrix, ROC-AUC — computed by the notebook during the build
Design target Approximately 85%+ validation accuracy (target, not a claimed result)
Inference Under ~1 second per image on CPU (design target)
Demo Flask web app with case gallery and explanation explorer

Project features

  • [Transfer-learned classifier] ResNet50 pre-trained on ImageNet with its head replaced and top residual blocks fine-tuned on RSNA chest X-rays, in a two-phase schedule (head first, then deeper blocks at lower learning rate)
  • [Three-class prediction] Outputs calibrated-style probabilities for Normal, No Lung Opacity / Not Normal, and Lung Opacity, with the winning class and confidence shown per radiograph
  • [Grad-CAM explanations] Every prediction ships with an attention heatmap over the lung fields, generated from the final convolutional block, so the decision is visually auditable
  • [Radiology-aware preprocessing] DICOM decode, resize to 224x224, CLAHE contrast enhancement and ImageNet normalization, with patient-level train/validation splits to prevent leakage
  • [Case-gallery demo app] Web interface with sample cases, run-inference panel, Grad-CAM toggle and an explanation explorer (layer selector, opacity slider)
  • [Training & evaluation dashboard] Epoch loss/accuracy curves, confusion matrix, ROC-AUC and per-class metrics, all logged by the notebook during the build
  • [Augmentation pipeline] Rotation, horizontal flip and brightness jitter applied during training for robustness to acquisition variation
  • [Viva-ready documentation] Report with data analysis, transfer-learning design choices, error analysis and the medical-prototype disclaimer stated explicitly

What is included

  • Complete source code (data pipeline, training script, Grad-CAM module, demo app)
  • Fine-tuned model weights exported from the included training run
  • Jupyter training and evaluation notebook (buyer-run procedure: train, validate, evaluate)
  • Project report PDF (background, dataset analysis, methodology, evaluation, error analysis, medical-prototype disclaimer)
  • PPT presentation for final review
  • Viva Q&A preparation document (transfer learning, ResNet, Grad-CAM, metrics, limitations)
  • Setup guide (environment, dataset download, training, running the demo)

Limitations & prerequisites

  • This is an academic research prototype, not a medical device: it must not be used for clinical diagnosis, and every prediction requires review by a qualified radiologist.
  • No accuracy or sensitivity figure is promised: performance depends on the data split, preprocessing, hyperparameters and training conditions, and the report documents the measured results of the actual build.
  • The model sees only frontal chest X-rays from the RSNA distribution; films from different scanners, pediatric cases or lateral views are outside its validated scope.
  • Grad-CAM heatmaps highlight correlated regions, not causal pathology — they aid inspection, not diagnosis.
  • The RSNA labels come from radiology reports, which carry their own noise; label quality bounds what any model can learn.

Frequently Asked Questions

Which dataset is used?

The RSNA Pneumonia Detection Challenge set: 26,684 frontal-view chest X-rays from the NIH Clinical Center, labeled Normal, No Lung Opacity / Not Normal, or Lung Opacity, with radiologist bounding boxes for pneumonia cases. It is public and downloadable from Kaggle.

What is transfer learning, and why use it here?

Instead of training from random weights, the project starts from a ResNet50 already trained on ImageNet and fine-tunes it on chest X-rays. This converges with far less labeled data and is the standard approach when labeled medical images are limited — the report explains the two-phase fine-tuning schedule.

Is the accuracy guaranteed?

No. The report states a design target of approximately 85%+ validation accuracy, but the actual numbers come from the training notebook run during the build — measured accuracy, confusion matrix and ROC-AUC on the held-out split. Nothing is claimed before it is measured.

Is this a medical device? Can it diagnose pneumonia?

No. This is an educational research prototype. It produces an assistive score that a qualified radiologist must review; it is not certified, not validated clinically, and never a substitute for professional diagnosis.

Can it work on my own X-ray images?

The demo accepts uploaded radiographs and runs the same pipeline, but predictions are only meaningful on frontal chest X-rays resembling the RSNA distribution. The report documents this scope limit explicitly.

Can the model be extended to other chest conditions?

Yes, as future scope: the same backbone can be fine-tuned for multi-label classification over the 14 NIH ChestX-ray14 pathologies, or for lesion localization using the RSNA bounding-box annotations. These are optional extensions, not part of the base build. Suitable for B.E./B.Tech final-year projects in Computer Science, AI/ML and Biomedical streams.

Components & software requirements
  • Python 3.10, PyTorch with torchvision ResNet50
  • OpenCV, pydicom (DICOM decoding), NumPy, pandas
  • scikit-learn (patient-level splits, metrics)
  • Matplotlib, Seaborn (training curves, confusion matrix, ROC)
  • Flask demo app (case gallery, inference panel, Grad-CAM viewer)
  • RSNA Pneumonia Detection Challenge dataset (26,684 frontal chest X-rays, NIH Clinical Center)
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.

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of multiple decision trees voting together into one final predictionStudents with basic Python and pandas skills who want a reliable first classifier for ML coursework and tabular data projects.

Random Forests Explained: Why Decision Trees Vote Better Together

Decision trees are readable but overfit; random forests fix this by training hundreds of varied trees on bootstrapped data with random feature subsets, then letting them vote. This guide explains Gini impurity, bagging, out-of-bag validation and the four hyperparameters that matter, with a complete scikit-learn workflow, honest feature-importance practices, and the mistakes students keep making.

Read guide
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Get a quotation