FleXray: Universal Clinical
X-ray Segmentation
Massachusetts Institute of Technology · Massachusetts General Hospital · Harvard Medical School
python -m pip install flexray
FleXray is a foundation model that segments anatomy from standard X-rays across diverse body regions, views, and acquisition settings. Trained on physics-based CT-to-DRR projections, real radiographs, and generative-model-enhanced DRRs, it predicts 60 anatomical structures, outperforms existing generalist baselines on diverse real X-ray datasets, and unlocks unique downstream workflows.
Interactive demo
Try FleXray in your browser
Upload a radiograph and FleXray segments every visible structure — entirely on your device. The model runs in your browser through WebGPU (or WebAssembly as a fallback), so your image never leaves your computer.
Research demo — not a medical device. Outputs are for illustration only and must not be used for clinical or diagnostic purposes.
The demo needs to be served over HTTP — opening
index.html directly from disk cannot load the model.
From the repository root run
.venv/bin/python -m http.server --directory site 8000 and open
http://localhost:8000/index.html#demo.
…or try a sample:
Quality: Low runs the flagship model once, Normal adds 8-pass test-time augmentation, High averages five FleXray models, and X-High does both. The first High or X-High run downloads the flagship model (~194 MB) plus four more (~776 MB); Low and Normal need only the flagship. Models stay cached by your browser.
Detected structures
Motivation
More than 2.3 billion conventional X-ray examinations are acquired each year, yet public pixel-level annotations cover only a narrow set of views and structures. Every radiograph collapses 3D anatomy into a 2D projection: overlapping organs, variable angles, scanner settings, field of view, and patient morphology can make even the same body region look radically different.
Labeled CT volumes offer a way out. Segmented CT scans turn scarce 3D annotations into many anatomically correct 2D training views.
Method: online CT-to-DRR rendering
FleXray ray-casts labeled CT volumes into digitally reconstructed radiographs (DRRs). Geometry, framing, and per-structure attenuation vary online, so a single subject becomes a stream of distinct paired images and masks—a new view at every training step. Randomly sampled cameras expose the model to anatomy from standard and non-standard acquisition angles.
- Load the CT volume, dense native labels, and physical-space affine.
- Sample detector geometry, view angle, field of view, and anatomy-centered crops.
- Ray-cast image intensities and masks into the common model label space.
Method: fluxifying DRRs
Raw DRRs are geometrically faithful but visually pristine—no film grain, no detector artifacts, no burned-in annotations. FleXray closes this gap by fluxifying its DRRs with Black Forest Labs’ off-the-shelf FLUX.2 image-editing model. It translates each clean rendering into a realistic radiograph with sensor noise, exposure variation, collimation, markers, and annotations, while preserving the underlying anatomy—so training images look like the real X-rays the model will see at test time.
Results
We evaluate FleXray on eight real X-ray datasets left out of training, spanning hand and wrist, elbow, lower limb, hip and pelvis, spine, ribs, adult and pediatric chest, and both radiography and fluoroscopy. Against released generalist baselines (PAXray, TotalSegmentator2D, FluoroSAM), FleXray reaches an equal-dataset mean Dice of 0.875 and the highest mean Dice among the generalist baselines on seven of eight datasets. Despite never training on these datasets, it approaches dataset-specific nnU-Nets trained on each dataset’s own labels (0.875 vs. 0.914) and exceeds them on DeepFluoro (0.916 vs. 0.866). Predictions stay anatomically coherent under variation in field of view, projection angle, image polarity, acquisition modality, and patient population.
Application: scoliosis measurement
Scoliosis severity is monitored with the Cobb angle, measured manually on radiographs with roughly 3–5° variability within an observer and 6–7° between observers. Without any task-specific training, FleXray derives each vertebra’s end-plate orientation from the centerline of its predicted mask and computes the major Cobb angle. On the AASCE MICCAI 2019 challenge test set, FleXray yields a measurable curve on every image (0 of 218 failures) and the lowest error of all methods: a mean absolute error of 5.13°, below inter-observer variability, versus 6.38° for TotalSegmentator2D, 24.9° for PAXray, and 31.8° for FluoroSAM. 61% of estimates fall within 5° of the reference and 88% within 10°.
Application: 2D/3D registration
Interventional specialties plan on 3D CT but navigate with live 2D fluoroscopy. Aligning the two, known as 2D/3D registration, is a brittle optimization with a small capture radius. We add a bidirectional Chamfer loss between FleXray’s segmentation of the X-ray and the projected CT structures to xvr, an image-based iterative registration pipeline; the term supplies informative gradients even when the rendered DRR and the X-ray do not overlap. On 213 held-out DeepFluoro X-rays, image-based registration from a manual frontal initialization fails on 86% of frames (median error 335 mm); adding the FleXray term lowers the median to 1.2 mm and the failure rate to 13%. From a foundation-model initialization, it lowers the failure rate from 7.0% to 3.3%, increasing successful registrations from 198 to 206 of 213 frames while keeping the median error near 1 mm. Success is defined as a mean target registration error below 10 mm.
Application: finetuning on new targets
As a foundation model, FleXray also transfers to targets outside its training vocabulary. We replace its output head and finetune on 1–100% of two new datasets, fine-grained pediatric pelvic anatomy in hip dysplasia (MTDDH) and bone tumors (BTXRD), against nnU-Net trained from scratch. Initialization from FleXray matters most where labels are scarcest: with 1% of MTDDH (6 patients) it reaches 0.898 mean Dice versus 0.869, and with 10% of BTXRD it reaches 23.2% detection AP50 versus 7.4%. AP50 measures average precision at a bounding-box intersection-over-union threshold of 0.5; this evaluation contains 354 annotated tumors in 281 positive radiographs. At full supervision, MTDDH Dice converges to 0.923 versus 0.921, while BTXRD AP50 reaches 53.1% versus 47.7%.
Resources
The release includes inference, the training data engine, online DRR
rendering, label protocols, experiment configuration, launch tools,
and an MCP server for AI clients. Models and data are hosted on
Hugging Face: the
VictorButoi/flexray
repository holds the flagship weights together with the
FluXray-proportion ensemble members that the demo’s High and
X-High modes average, and the
flexray-data
release repackages every redistributable real X-ray source in the
FleXray label protocol, includes the generated FluXray database, and
documents how to obtain the sources we cannot redistribute.
- In-browser demoRuns locally via WebGPU ↑
- Source codeGitHub ↗
- Pretrained modelsHugging Face ↗
- Training & evaluation dataHugging Face ↗
- Model release statusModel zoo ↗
- MCP serverUse FleXray from Claude & AI agents ↗
- CitationBibTeX ↓
Limitations
FleXray currently targets conventional, non-dental and non-mammographic radiographs. Its public output space covers anatomy rather than pathology; laterality, uncertainty estimation, and broader clinical validation remain future work. The release is intended for research use.
Acknowledgements
This work was supported by the National Science Foundation Graduate Research Fellowship Program, Quanta Computer Inc., and the NIH, with grants R01 EB033773 and S10 OD038222. Compute provided by the Massachusetts Life Sciences Center (MLSC).
Citation
If you use FleXray or build on its methods in your work, please cite the associated paper:
@misc{butoi2026flexray,
title={FleXray: Universal Clinical X-ray Segmentation},
author={Victor Ion Butoi and Vivek Gopalakrishnan and John V. Guttag and Adrian V. Dalca and Neel Dey},
year={2026},
eprint={2609.26756},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2609.26756},
}