TinyImageNet

class probly.datasets.torch.TinyImageNet(root: str | Path, split: str = 'train', transform: Callable[..., Any] | None = None, target_transform: Callable[..., Any] | None = None, *, download: bool = False)[source]

Bases: VisionDataset

A Dataset class for the Tiny ImageNet dataset introduced in [LY15].

Tiny ImageNet is a 200-class subset of ImageNet downsampled to 64x64, holding 500 training and 50 validation images per class, with hard integer labels. The data can be found at https://cs231n.stanford.edu/tiny-imagenet-200.zip and fetched with download=True (a single ~237 MB zip). Class indices follow the sorted WordNet ids, matching torchvision.datasets.ImageFolder and torchvision.datasets.ImageNet; note that the shipped wnids.txt is unsorted, so this order deliberately differs from that file’s line order. The shipped test split is excluded because its labels were never released.

Initialize an instance of the TinyImageNet class.

Parameters:
  • root – Root directory containing (or to download into) the tiny-imagenet-200 folder.

  • split – Which split to load; must be one of TinyImageNet.splits.

  • transform – Optional transform to apply to the image.

  • target_transform – Optional transform to apply to the integer label.

  • download – Whether to download the Tiny ImageNet zip from Stanford if missing.

Raises:
base_folder = 'tiny-imagenet-200'
class_to_idx: dict[str, int]

Mapping from WordNet id to class index.

classes: list[str]

The 200 WordNet ids, sorted, so that classes[i] is the wnid of class index i.

extra_repr() str[source]
filename = 'tiny-imagenet-200.zip'
samples: list[tuple[Path, int]]

The (image path, class index) pairs of the selected split, ordered by path.

splits: tuple[str, ...] = ('train', 'val')

The two labeled splits; the shipped test split has no public labels.

targets: list[int]

Hard integer class labels, one per image.

url = 'https://cs231n.stanford.edu/tiny-imagenet-200.zip'
zip_md5 = '90528d7ca1a48142e341f4ef8d21d0de'