CXR Lines and Tubes
Model description
This repository contains a research pipeline for detecting and classifying
endotracheal tubes, nasogastric tubes, central venous catheters, and Swan-Ganz
catheters on frontal chest radiographs, together with carina localization.
The release contains four model groups:
- an EfficientNet-B1 encoder with separate U-Net decoders for device-agnostic
and device-family line/distal-tip masks;
- an EfficientNetV2-B0/DeepLabV3+ carina heatmap and coordinate model;
- a five-fold EfficientNet-B1 multilabel classifier using RGB plus predicted
device and carina probability maps; and
- a lightweight FastViT four-family presence classifier for ETT, NGT, CVC,
and Swan-Ganz screening.
The segmentation and competition-classification models are trained on RANZCR
CLiP. The presence classifier additionally uses a non-overlapping subset of NIH
ChestX-ray14 with thresholded teacher labels. The models are not medical devices
and are not validated for patient-care decisions.
Intended use
Intended uses are research, reproducibility, model comparison, educational
visualization, and development of human-reviewed clinical research tools.
Do not use the models as the sole basis for diagnosis, tube repositioning,
triage, or any other patient-care decision. A qualified clinician must review
the original radiograph and relevant clinical context.
Inputs and outputs
Device model
- Input: one grayscale chest radiograph, directly resized to 1024 x 1024.
- Agnostic outputs: line/tube union and distal-tip union probabilities.
- Family outputs: independent line and distal-tip probabilities for ETT, NGT,
CVC, and Swan Ganz.
- Each device polyline contributes one distal-tip target: the most inferior
endpoint for ETT/NGT and the endpoint closest to normalized image center for
CVC/Swan-Ganz. An incompletely imaged NGT uses its most inferior visible
endpoint, which is not necessarily its true anatomical tip.
Carina model
- Input: one grayscale chest radiograph, directly resized to 512 x 512.
- Outputs: carina heatmap, differentiable normalized coordinate, and peak
coordinate.
Classifier
- Input: a 512 x 512 six-channel tensor consisting of RGB plus agnostic line,
distal-tip, and carina probabilities.
- Output labels:
- ETT Abnormal
- ETT Borderline
- ETT Normal
- NGT Abnormal
- NGT Borderline
- NGT Incompletely Imaged
- NGT Normal
- CVC Abnormal
- CVC Borderline
- CVC Normal
- Swan Ganz Catheter Present
The internal classifier also predicts a no-ETT class to form a four-way ETT
softmax; that auxiliary output is excluded from the competition mean AUROC.
Lightweight device-presence classifier
- Input: one grayscale chest radiograph, directly resized to 384 x 384.
- Outputs: independent ETT, NGT, CVC, and Swan-Ganz presence probabilities.
- Training includes an inexpensive three-block depthwise-separable U-Net decoder
for auxiliary family centerline supervision.
- Only the encoder, pooling layer, and four-logit classification head are needed
for production screening.
Training data
The training set contains 30,083 RANZCR CLiP radiographs. Device polylines are
available for 9,095 images, and 5,275 images have a valid single-point carina
annotation under this project's filtering rule.
The presence-classifier training set first adds 17,869 non-RANZCR NIH
radiographs whose CVC ensemble probability is below 0.95, a cutoff selected
after manual review. A second controlled expansion adds 13,579 studies from
previously unused patients only when all five FastViT teachers assign CVC
probability below 0.001. There is at most one expansion study per patient. All
31,448 NIH rows are treated as CVC-negative, are training-only, and are excluded
from every validation fold. ETT, NGT, and Swan-Ganz labels are thresholded at
0.5 from the original five-model B1 ensemble.
On exact concatenated hard-label RANZCR OOF predictions, the expansion improved
CVC AUROC from 0.976654 to 0.977892 and mean family AUROC from 0.992299 to
0.992549. CVC improved in four of five folds. These NIH labels remain
model-derived rather than verified ground truth.
The release links to the original datasets and does not redistribute source
radiographs or annotations. Code is MIT-licensed. The model weights are
released for non-commercial research, reproducibility, and educational use
under the terms described in LICENSE.md.
Training procedure
- Five patient-disjoint folds with approximately balanced competition labels.
- Direct square resize without aspect-ratio preservation or padding.
- ImageNet initialization for all encoders/classifier backbones.
- Device Stage 1: distal-v4 B1 regular U-Net, 1024, 30 epochs, BCE plus
low-weight line and distal-tip soft Dice.
- Device Stage 2: frozen eval-mode Stage 1 encoder, separate family U-Net decoder,
1024, 15 epochs; Swan-Ganz is sampled to approximately 10% prevalence.
- Carina: B0 DeepLabV3+, 512, 30 epochs, BCE plus coordinate Smooth L1.
- Classifier: B1, 512, 30 epochs, BF16 mixed precision.
- Segmentation features for annotated classifier images are strictly OOF;
task-unannotated images use a five-fold probability ensemble.
Evaluation
Completed segmentation results:
| Task | Metric | Five-fold mean |
|---|
| Device agnostic lines | Dice at 0.5 | 0.7501 |
| Device agnostic distal tips | Dice at 0.5 | 0.6560 |
| Device family | Dice | 0.5855 |
| Device family lines | Dice | 0.5906 |
| Device family distal tips | Dice | 0.5804 |
| Carina | Heatmap Dice | 0.5236 |
| Carina | Normalized landmark error | 0.0145 |
| Carina | PCK at 2% diagonal | 0.7834 |
Reference five-channel classifier results:
| Metric | Value |
|---|
| Raw OOF mean AUROC | 0.96742 |
| Fold-rank-normalized OOF mean AUROC | 0.96769 |
Six-channel classifier best-checkpoint validation results:
| Fold | AUROC |
|---|
| 0 | 0.9652 |
| 1 | 0.9699 |
| 2 | 0.9697 |
| 3 | 0.9682 |
| 4 | 0.9690 |
| Mean | 0.9684 |
The six-channel mean averages independently selected fold checkpoints and is not
a concatenated OOF AUROC.
Kaggle late-submission evaluation
Matched ensembles used the same number of segmentation teachers and
classification folds. Model probabilities are averaged in probability space;
no rank normalization is applied to the Kaggle test predictions. Scores are
from late submissions to the original RANZCR CLiP leaderboard.
| Ensemble | Notebook version | Private AUROC | Public AUROC |
|---|
| K1 | 4 | 0.96959 | 0.96085 |
| K2 | 4 | 0.97143 | 0.96911 |
| K3 | 1 | 0.97256 | 0.96967 |
| K4 | 1 | 0.97273 | 0.97014 |
| K5 | 1 | 0.97288 | 0.97059 |
K5 distal-v4 is the selected release ensemble. Scores improved monotonically
with ensemble size on both leaderboard splits. Relative to the original
two-endpoint K5, distal-v4 was 0.00026 lower privately and 0.00139 lower
publicly, while providing the clinically useful single-distal-endpoint contract.
These leaderboard scores evaluate the competition's 11-label classification
task and do not establish clinical performance.
Potential future additions:
- Add a concatenated six-channel OOF AUROC if it is generated.
- Add per-label AUROC.
- Include confidence intervals or fold standard deviation where appropriate.
Limitations and biases
- Single competition dataset; external-site generalization is unknown.
- Synthetic thick polyline masks are not precise device-boundary annotations.
- The incompletely imaged NGT target is a visible inferior endpoint rather than
a guaranteed anatomical tip.
- Rare Swan-Ganz examples limit family segmentation reliability.
- The presence classifier's NIH labels are model-derived and can contain label
errors despite the manually selected CVC cutoff.
- The remaining NIH cohort has no hard device-presence labels and was selected
by an earlier model. Its prediction distribution cannot establish prevalence
or calibration.
- Devices can overlap, exit the field of view, or be incompletely imaged.
- Performance may change with acquisition hardware, post-processing, image
orientation, patient population, anatomy, disease burden, and unseen devices.
- AUROC does not establish calibration or a safe clinical operating point.
- OOF/ensemble feature routing matches this research protocol and must be
reproduced exactly for comparable results.
Ethical and safety considerations
The model can be confidently wrong. Visual overlays may encourage automation
bias even when localization is inaccurate. Interfaces should display uncertainty,
retain the original image, identify model/version provenance, and require human
review. Do not suppress or replace the source radiograph with generated masks.
Hugging Face Space integration
The companion Space runs the lightweight four-family presence classifier
first. When a configurable family threshold is reached, users may run the larger
device segmentation, carina localization, and 11-label classification pipeline.
The model repository contains every checkpoint from every fold rather than
separate reduced ensembles. Models are loaded lazily, and users can
choose the number of folds independently for presence screening, device
segmentation, carina localization, and final classification.
Recommended profiles:
| Profile | Presence folds | Device folds | Carina folds | Classifier folds | Intended use |
|---|
screen | 5 | 0 | 0 | 0 | Reliable low-cost device-family screening |
fast | 1 | 1 | 1 | 1 | Lowest-latency full result |
balanced | 5 | 3 | 3 | 3 | Default speed/performance tradeoff |
max | 5 | 5 | 5 | 5 | Highest-performing release ensemble |
The distal-v4 K3 classifier pipeline reached 0.97256 private and 0.96967 public
AUROC, close to K5 at 0.97288 and 0.97059. This supports K3 as the interactive default
while retaining K5 for batch or maximum-quality inference.
Fold counts resolve to explicit, versioned fold-ID lists rather than depending
on filesystem order. Advanced callers may provide exact fold IDs. The default
K1–K5 device, carina, and classifier selections must reproduce the matched
ensembles used for the Kaggle results; arbitrary unmatched combinations are
supported but are not covered by those leaderboard measurements.
Presence outputs are raw sigmoid model scores with no post-hoc probability
transformation. These scores must not be interpreted as clinical probabilities.
The companion Space uses 0.5 as an explicitly uncalibrated raw-score screening
policy. If all four device-family scores are below 0.5, the larger pipeline is
skipped unless the user selects the force-full-pipeline option. Changing the
number or identity of folds changes the score distribution, so custom fold
selections must not silently treat this threshold as calibrated.
The companion interface:
- display the original radiograph alongside continuous-probability overlays;
- report device-presence probabilities and the exact model version;
- display the active profile and fold IDs for every model component;
- allow independent fold-count overrides and a force-full-pipeline option;
- keep screening thresholds configurable until externally validated;
- explain when the larger pipeline was skipped; and
- present a prominent research-only, non-clinical-use warning.
The production runtime wrapper must return raw scores and identify any
raw-score threshold used for staged execution. No internal calibration
parameters are distributed with or loaded by the public release.
Release contents
Reproducibility
The source repository records configs, losses, metrics, fold generation, OOF
routing, and negative experiments. See
docs/RANZCR_PIPELINE.md
and
docs/EXPERIMENT_HISTORY.md.
Author and contact: Ian Pan,
https://ianpan.me
Dataset citations
Space input and ETT–carina measurement
The companion Space accepts PNG, JPEG, and single-frame monochrome DICOM.
DICOM images are transformed with the modality LUT and pydicom
apply_voi_lut, converted to 8-bit, and inverted when the photometric
interpretation is MONOCHROME1.
When the model predicts ETT presence and localizes both the distal ETT tip and
carina, the Space reports Euclidean distance in the original upload geometry.
It uses centimeters when DICOM pixel spacing is available and pixels otherwise.
This automated measurement has not been clinically validated and is presented
for research and demonstration only.