Abstract
TorchXRayVision is an open source software library for working with chest X-ray datasets and deep learning models. It provides a common interface and common pre-processing chain for a wide set of publicly available chest X-ray datasets. In addition, a number of classification and representation learning models with different architectures, trained on different data combinations, are available through the library to serve as baselines or feature extractors.
Introduction
Chest X-rays (CXRs) are the most common medical imaging test globally, resulting in a massive volume of open-access data and publications. However, the field suffers from a lack of standardization. Every dataset comes with its own quirks: different image formats, varying label sets (e.g., "Effusion" vs. "Pleural Effusion"), and inconsistent pre-processing requirements. For a researcher, this means spending more time writing boilerplate data-loading code than actually innovating. Furthermore, models trained on one hospital's data often fail when tested on another's due to "distribution shift"—differences in hardware, patient demographics, or clinical protocols. TorchXRayVision (XRV) is an open-source library designed to solve this "fragmentation" problem.
Methods and Datasets
The library is built on top of PyTorch and follows an object-oriented design to provide a unified interface for over 14 chest X-ray datasets. Key technical features include standardized pre-processing, where all images are automatically resized and scaled to a specific pixel range ([-1024, 1024]). This ensures that a model trained on one dataset can be immediately applied to another without manual re-scaling.
The library maps disparate labels from various datasets to a standard set of 18 pathologies. It includes "Core" models trained on massive multi-dataset combinations, as well as "Baseline" models from other major research groups. These models follow a standardized naming convention to help researchers track architecture, resolution, and training data.
TorchXRayVision integrates an impressive array of public datasets, including major benchmarks like NIH (ChestX-ray8), CheXpert, MIMIC-CXR, and PadChest, as well as specialized sets for the RSNA Pneumonia Challenge and COVID-19. In total, the library provides access to over 700,000 positive labels across various indications.
Key Results and Insights
The primary innovation of TorchXRayVision is the decoupling of datasets from models, allowing for "plug-and-play" experimentation. The library successfully maps diverse data into 18 independent output classes, handling missing data gracefully.
Using UMAP (Uniform Manifold Approximation and Projection), the authors demonstrate that the library’s pre-trained models successfully cluster different pathologies in a high-dimensional feature space. This proves that the models have learned meaningful medical representations rather than just memorizing dataset-specific noise.
Beyond classification, the library includes support for pathology masks and autoencoders for unsupervised representation learning. Models can also be used as "frozen" feature extractors, turning raw pixels into compact vectors for downstream tasks like patient similarity search or few-shot learning.
Conclusion
TorchXRayVision provides a critical infrastructure for medical imaging research, enabling reproducibility and easier cross-dataset evaluation. While it is a research tool and not intended for clinical diagnostic use, its unified pathology mapping and pre-trained models have already seen utility in studies ranging from patient severity prediction to the investigation of "shortcut learning" in AI. The project remains open-source, inviting community contributions to further expand its dataset and model offerings.
Summary updated