Skip to main content

A small example package

Project description


A library for chest X-ray datasets and models. Including pre-trainined models.

This code is still under development

Getting started

pip install torchxrayvision

import torchxrayvision as xrv

These are default pathologies:


 'Lung Lesion',
 'Lung Opacity',
 'Enlarged Cardiomediastinum']


model = xrv.models.DenseNet(weights="all")
model = xrv.models.DenseNet(weights="kaggle")
model = xrv.models.DenseNet(weights="nih")
model = xrv.models.DenseNet(weights="chex")
model = xrv.models.DenseNet(weights="minix_nb")
model = xrv.models.DenseNet(weights="minix_ch")


transform = torchvision.transforms.Compose([xrv.datasets.XRayCenterCrop(),

d_kaggle = xrv.datasets.Kaggle_Dataset(imgpath="path to stage_2_train_images_jpg",

d_chex = xrv.datasets.CheX_Dataset(imgpath="path to CheXpert-v1.0-small",
                                   csvpath="path to CheXpert-v1.0-small/train.csv",

d_nih = xrv.datasets.NIH_Dataset(imgpath="path to NIH images")

d_nih2 = xrv.datasets.NIH_Google_Dataset(imgpath="path to NIH images")

d_pc = xrv.datasets.PC_Dataset(imgpath="path to image folder")

d_covid19 = xrv.datasets.COVID19_Dataset() # specify imgpath and csvpath for the dataset

dataset tools

relabel_dataset will align labels to have the same order as the pathologies argument.

xrv.datasets.relabel_dataset(xrv.datasets.default_pathologies , d_nih) # has side effects


Joseph Paul Cohen, Joseph Viviano, Mohammad Hashir, and Hadrien Bertrand. 
TorchXrayVision: A library of chest X-ray datasets and models., 2020


Cohen, J. P., Hashir, M., Brooks, R., & Bertrand, H. 
On the limits of cross-domain generalization in automated X-ray prediction. 2020 
arXiv preprint [](

  title={On the limits of cross-domain generalization in automated X-ray prediction},
  author={Cohen, Joseph Paul and Hashir, Mohammad and Brooks, Rupert and Bertrand, Hadrien},
  journal={arXiv preprint arXiv:2002.02497},

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for torchxrayvision, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size torchxrayvision-0.0.3-py3-none-any.whl (16.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size torchxrayvision-0.0.3.tar.gz (12.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page