sparseml.pytorch.datasets.classification package

Submodules

sparseml.pytorch.datasets.classification.cifar module

CIFAR dataset implementations for the image classification field in computer vision. More info for the dataset can be found here.

class sparseml.pytorch.datasets.classification.cifar.CIFAR100Dataset(root: str = '~/.cache/nm_datasets/cifar100', train: bool = True, rand_trans: bool = False)[source]

Bases: torchvision.datasets.cifar.CIFAR100

Wrapper for the CIFAR100 dataset to apply standard transforms.

Parameters
  • root – The root folder to find the dataset at, if not found will download here

  • train – True if this is for the training distribution, False for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

class sparseml.pytorch.datasets.classification.cifar.CIFAR10Dataset(root: str = '~/.cache/nm_datasets/cifar10', train: bool = True, rand_trans: bool = False)[source]

Bases: torchvision.datasets.cifar.CIFAR10

Wrapper for the CIFAR10 dataset to apply standard transforms.

Parameters
  • root – The root folder to find the dataset at, if not found will download here

  • train – True if this is for the training distribution, false for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

sparseml.pytorch.datasets.classification.imagefolder module

Imagenet dataset implementations for the image classification field in computer vision. More info for the dataset can be found here.

class sparseml.pytorch.datasets.classification.imagefolder.ImageFolderDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]

Bases: torchvision.datasets.folder.ImageFolder, sparseml.pytorch.datasets.image_classification.ffcv_dataset.FFCVImageNetDataset

Wrapper for the ImageFolder dataset to apply standard transforms. Additionally scales the inputs based off of the imagenet means and stds.

Dataset should be in the following form locally on disk:

root/dog/xxx.png
root/dog/xxy.png
root/dog/xxz.png

root/cat/123.png
root/cat/nsdf3.png
root/cat/asd932.png
Parameters
  • root – The root folder to find the dataset at

  • train – True if this is for the training distribution, False for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

  • image_size – the size of the image to output from the dataset

property num_classes

sparseml.pytorch.datasets.classification.imagenet module

Imagenet dataset implementations for the image classification field in computer vision. More info for the dataset can be found here.

class sparseml.pytorch.datasets.classification.imagenet.ImageNetDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]

Bases: torchvision.datasets.folder.ImageFolder, sparseml.pytorch.datasets.image_classification.ffcv_dataset.FFCVImageNetDataset

Wrapper for the ImageNet dataset to apply standard transforms.

Parameters
  • root – The root folder to find the dataset at

  • train – True if this is for the training distribution, False for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

  • image_size – the size of the image to output from the dataset

sparseml.pytorch.datasets.classification.imagenette module

Imagenette and Imagewoof dataset implementations for the image classification field in computer vision. More info for the dataset can be found here.

class sparseml.pytorch.datasets.classification.imagenette.ImagenetteDataset(root: str = '~/.cache/nm_datasets/imagenette', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Optional[int] = None, download: bool = True)[source]

Bases: sparseml.utils.datasets.imagenette.ImagenetteDownloader, torchvision.datasets.folder.ImageFolder, sparseml.pytorch.datasets.image_classification.ffcv_dataset.FFCVImageNetDataset

Wrapper for the imagenette (10 class) dataset that fastai created. Handles downloading and applying standard transforms.

Parameters
  • root – The root folder to find the dataset at, if not found will download here if download=True

  • train – True if this is for the training distribution, False for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

  • dataset_size – The size of the dataset to use and download: See ImagenetteSize for options

  • image_size – The image size to output from the dataset

  • download – True to download the dataset, False otherwise

class sparseml.pytorch.datasets.classification.imagenette.ImagenetteSize(value)[source]

Bases: enum.Enum

Dataset size for Imagenette / Imagewoof. full does not resize the original dataset at all. s320 resizes the images to 320px. s160 resizes the images to 160px.

full = 'full'
s160 = 's160'
s320 = 's320'
class sparseml.pytorch.datasets.classification.imagenette.ImagewoofDataset(root: str = '~/.cache/nm_datasets/imagewoof', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Optional[int] = None, download: bool = True)[source]

Bases: sparseml.utils.datasets.imagenette.ImagewoofDownloader, torchvision.datasets.folder.ImageFolder, sparseml.pytorch.datasets.image_classification.ffcv_dataset.FFCVImageNetDataset

Wrapper for the imagewoof (10 class) dataset that fastai created. Handles downloading and applying standard transforms. More info for the dataset can be found here <https://github.com/fastai/imagenette>

Parameters
  • root – The root folder to find the dataset at, if not found will download here if download=True

  • train – True if this is for the training distribution, False for the validation

  • rand_trans – True to apply RandomCrop and RandomHorizontalFlip to the data, False otherwise

  • dataset_size – The size of the dataset to use and download: See :py:func ~ImagewoofSize for options

  • image_size – The image size to output from the dataset

  • download – True to download the dataset, False otherwise

sparseml.pytorch.datasets.classification.mnist module

MNIST dataset implementations for the image classification field in computer vision. More info for the dataset can be found here.

class sparseml.pytorch.datasets.classification.mnist.MNISTDataset(root: str = '~/.cache/nm_datasets/mnist', train: bool = True, flatten: bool = False)[source]

Bases: torchvision.datasets.mnist.MNIST

Wrapper for MNIST dataset to apply standard transforms.

Parameters
  • root – The root folder to find the dataset at, if not found will download here

  • train – True if this is for the training distribution, False for the validation

  • flatten – flatten the MNIST image from (1, 28, 28) to (784)

Module contents

Datasets related to image classification field in computer vision