Enable pathology masks in datasets
mainMany datasets (like NIH_Dataset and CheXpert_Dataset) support pixel-level segmentation masks. When initializing the dataset, set pathology_masks=True.
Each sample returned by the dataset will then include a "pathology_masks" key, which maps pathology names to binary pixel arrays of the same spatial size as the image ("img").
import torchxrayvision as xrv
ds = xrv.datasets.NIH_Dataset(
imgpath="/data/NIH",
pathology_masks=True,
)
sample = ds[0]
print(sample.keys()) # dict_keys(['img', 'lab', 'pathology_masks', ...])
print(sample["pathology_masks"].keys()) # e.g. {'Atelectasis': array(...)}