class avalanche.benchmarks.datasets.MiniImageNetDataset(imagenet_path: ~typing.Union[str, ~pathlib.Path], split: ~typing.Literal['all', 'train', 'val', 'test'] = 'all', resize_to: ~typing.Union[int, ~typing.Tuple[int, int]] = 84, loader=<function default_loader>)[source]

The MiniImageNet dataset.

This implementation is based on the one from https://github.com/yaoyao-liu/mini-imagenet-tools. Differently from that, this class doesn’t rely on a pre-generated mini imagenet folder. Instead, this will use the original ImageNet folder by resizing images on-the-fly.

The list of included files are the ones defined in the CSVs taken from the aforementioned repository. Those CSVs are generated by Ravi and Larochelle. See the linked repository for more details.

Exactly as happens with the torchvision ImageNet class, textual class labels (wnids) such as “n02119789”, “n02102040”, etc. are mapped to numerical labels based on their ascending order.

All the fields found in the torchvision implementation of the ImageNet dataset (wnids, wnid_to_idx, classes, class_to_idx) are available.

__init__(imagenet_path: ~typing.Union[str, ~pathlib.Path], split: ~typing.Literal['all', 'train', 'val', 'test'] = 'all', resize_to: ~typing.Union[int, ~typing.Tuple[int, int]] = 84, loader=<function default_loader>)[source]

Creates an instance of the Mini ImageNet dataset.

This dataset allows to obtain the whole dataset or even only specific splits. Beware that, when using a split different that “all”, the returned dataset will contain patterns of a subset of the 100 classes. This happens because MiniImagenet was created with the idea of training, validating and testing on a disjoint set of classes.

This implementation uses the filelists provided by https://github.com/yaoyao-liu/mini-imagenet-tools, which are the ones generated by Ravi and Larochelle (see the linked repo for more details).

  • imagenet_path – The path to the imagenet folder. This has to be the path to the full imagenet 2012 folder (plain, not resized). Only the “train” folder will be used. Because of this, passing the path to the imagenet 2012 “train” folder is also allowed.

  • split – The split to obtain. Defaults to “all”. Valid values are “all”, “train”, “val” and “test”.

  • resize_to – The size of the output images. Can be an int value or a tuple of two ints. When passing a single int value, images will be resized by forcing as 1:1 aspect ratio. Defaults to 84, which means that images will have size 84x84.


__init__(imagenet_path[, split, resize_to, ...])

Creates an instance of the Mini ImageNet dataset.





The path to the "train" folder of full imagenet 2012 directory.


The required split.


The size of the output images, as a two ints tuple.


The paths to images.


The class labels for the patterns.


The list of wnids (the textual class labels, such as "n02119789").


A dictionary mapping wnids to numerical labels in range [0, 100).


A list mapping numerical labels (the element index) to a tuple of human readable categories.


A dictionary mapping each string of the tuples found in the classes field to their numerical label.