MedMNISTC¶
- class probly.datasets.torch.MedMNISTC(root: str | Path, dataset: str, corruption: str, severity: int, transform: Callable[..., Any] | None = None, target_transform: Callable[..., Any] | None = None, *, download: bool = False)[source]¶
Bases:
VisionDatasetA Dataset class for the MedMNIST-C corruption benchmark introduced in [SDL24].
One instance holds one MedMNIST test set for a single dataset (
dataset, e.g."dermamnist"),corruptiontype, andseveritylevel (1-5), with hard integer labels. The release ships one.npzper(dataset, corruption)at 224x224 (https://zenodo.org/records/11471504), stacking all five severities intest_imagesas(5*N, H, W[, C])uint8 with the same severity-major layout as CIFAR-10-C, and can be fetched withdownload=True. Loading is resolution-agnostic, so pass atransform(e.g.Resize) to reach a different resolution. ChestMNIST is excluded because it is the only multi-label MedMNIST2D task, whereas this loader returns hard integer labels.Initialize an instance of the MedMNISTC class.
- Parameters:
root – Root directory containing (or to download into) the
medmnist_cfolder.dataset – Which MedMNIST dataset to load (its MedMNIST “flag”); must be one of
MedMNISTC.corruptions.corruption – Corruption type; must be one of
MedMNISTC.corruptions[dataset].severity – Corruption severity in 1..5.
transform – Optional transform to apply to the image.
target_transform – Optional transform to apply to the integer label.
download – Whether to download the dataset’s archive from Zenodo if missing. Not every dataset is published on Zenodo (e.g.
"tissuemnist"must be generated locally).
- Raises:
ValueError – If
datasetorcorruptionis unknown orseverityis not in 1..5.RuntimeError – If the data is missing and
downloadis False, or ifdownloadis requested for a dataset that is not available on Zenodo.
- base_folder = 'medmnist_c'¶
- corruptions: ClassVar[dict[str, tuple[str, ...]]] = {'bloodmnist': ('pixelate', 'jpeg_compression', 'defocus_blur', 'motion_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'saturate', 'stain_deposit', 'bubble'), 'breastmnist': ('pixelate', 'jpeg_compression', 'speckle_noise', 'motion_blur', 'brightness_up', 'brightness_down', 'contrast_down'), 'dermamnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'impulse_noise', 'shot_noise', 'defocus_blur', 'motion_blur', 'zoom_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'black_corner', 'characters'), 'octmnist': ('pixelate', 'jpeg_compression', 'speckle_noise', 'defocus_blur', 'motion_blur', 'contrast_down'), 'organamnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'impulse_noise', 'shot_noise', 'gaussian_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'gamma_corr_up', 'gamma_corr_down'), 'organcmnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'impulse_noise', 'shot_noise', 'gaussian_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'gamma_corr_up', 'gamma_corr_down'), 'organsmnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'impulse_noise', 'shot_noise', 'gaussian_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'gamma_corr_up', 'gamma_corr_down'), 'pathmnist': ('pixelate', 'jpeg_compression', 'defocus_blur', 'motion_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'saturate', 'stain_deposit', 'bubble'), 'pneumoniamnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'impulse_noise', 'shot_noise', 'gaussian_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down', 'gamma_corr_up', 'gamma_corr_down'), 'retinamnist': ('pixelate', 'jpeg_compression', 'gaussian_noise', 'speckle_noise', 'defocus_blur', 'motion_blur', 'brightness_down', 'contrast_down'), 'tissuemnist': ('pixelate', 'jpeg_compression', 'impulse_noise', 'gaussian_blur', 'brightness_up', 'brightness_down', 'contrast_up', 'contrast_down')}¶
2406.17536, Table 1).
- Type:
Per-dataset corruption types shipped with MedMNIST-C (arXiv
- data: np.ndarray¶
Array of shape (N, H, W) or (N, H, W, C), uint8, for the selected dataset/corruption/severity.
- md5s: ClassVar[dict[str, str]] = {'bloodmnist': 'daba10a010064a9e38f0d09b498bcf18', 'breastmnist': 'c755e51825c074706524ea6b2c77a10b', 'dermamnist': '19c88c74c104655d5f668e158e56451d', 'octmnist': '40389bc54256edecd09ee4bd028c7e6a', 'organamnist': 'ff4ad0f53934ddf6a2330065d581990c', 'organcmnist': '2a649c94473ab9126130af8205d6c89b', 'organsmnist': '1dbf4d814725adc307ba9ffe5edf061a', 'pathmnist': 'bf62498906ec0383c3ec5ff12ac70c00', 'pneumoniamnist': 'c499a47a64a000b579b23920bf80a95a', 'retinamnist': '80a2fa4c9b7fa2176606be825dfdef6e'}¶
//zenodo.org/records/11471504 (10 of the 11 supported datasets; TissueMNIST-C is registry-only and must be generated locally).
- Type:
Per-dataset md5 of the released archive at https