CIFAR10C

class probly.datasets.torch.CIFAR10C(root: str | Path, corruption: str, severity: int, transform: Callable[..., Any] | None = None, target_transform: Callable[..., Any] | None = None, *, download: bool = False)[source]

Bases: VisionDataset

A Dataset class for the CIFAR-10-C corruption benchmark introduced in [HD19].

One instance holds the 10,000 CIFAR-10 test images for a single corruption type at a single severity level (1-5), with hard integer labels. The data can be found at https://zenodo.org/records/2535967 and fetched with download=True (a single ~2.9 GB CIFAR-10-C.tar that covers all corruption types).

Initialize an instance of the CIFAR10C class.

Parameters:
  • root – Root directory containing (or to download into) the CIFAR-10-C folder.

  • corruption – Corruption type; must be one of CIFAR10C.corruptions.

  • 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 CIFAR-10-C tar from Zenodo if missing.

Raises:
  • ValueError – If corruption is unknown or severity is not in 1..5.

  • RuntimeError – If the data is missing and download is False.

base_folder = 'CIFAR-10-C'
corruptions: tuple[str, ...] = ('gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', 'brightness', 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression', 'speckle_noise', 'gaussian_blur', 'spatter', 'saturate')

The 19 corruption types shipped with CIFAR-10-C (15 main + 4 extra).

data: ndarray

Array of shape (10000, 32, 32, 3), uint8, for the selected corruption and severity.

extra_repr() str[source]
filename = 'CIFAR-10-C.tar'
tar_md5 = '56bf5dcef84df0e2308c6dcbcbbd8499'
targets: list[int]

Hard integer class labels, one per image.

url = 'https://zenodo.org/records/2535967/files/CIFAR-10-C.tar'