spyrit.misc.statistics.stat_imagenet
- spyrit.misc.statistics.stat_imagenet(stat_root=PosixPath('stats'), data_root=PosixPath('data/ILSVRC2012_img_test_v10102019'), img_size: int = 64, batch_size: int = 1024, get_size: str = 'resize', n_loop: int = 1, device=device(type='cpu'), normalize=True, ext='npy', **rcrop_kwargs)[source]
- Args:
stat_root: path to the folder where the mean and covariance matrices are saveddata_root: path to image database.data_rootneeds to have all images in a subfolderimg_size: image sizebatch_size: batch sizeget_size: specifies how images of sizeimg_sizeare obtained (seedata_loaders_imagenet)‘original’: random crop with padding
‘resize’: resize
‘ccrop’: center crop
‘rcrop’: random crop
n_loop(int, optional): Number of loops across image database. Defaults to 1. n_loop > 1 is only relevant for dataloaders with random transforms (e.g., ‘rcrop’ resizing)normalize: Torchvision datasets are images in the range [0, 1]. Settingnormalizeto True sends them to the range [-1, 1]. Whennormalizeis False, the images are left in the range [0, 1].ext(string): Extension of saved files:‘npy’ for numpy (default),
‘pt’ for pytorch,
do not save files otherwise.
rcrop_kwargs: Additional arguments for random crop- Example:
>>> data_root = Path('../data/ILSVRC2012_img_test_v10102019/') >>> stat_root = Path('../stat/ILSVRC2012_img_test_v10102019') >>> from spyrit.misc.statistics import stat_imagenet >>> stat_imagenet(stat_root = stat_root, data_root = data_root)