vision.datasets

Gluon provides pre-defined vision datasets functions in the mxnet.gluon.data.vision.datasets module.

Dataset container.

Classes

MNIST([root, train, transform])

MNIST handwritten digits dataset from http://yann.lecun.com/exdb/mnist

FashionMNIST([root, train, transform])

A dataset of Zalando’s article images consisting of fashion products,

CIFAR10([root, train, transform])

CIFAR10 image classification dataset from https://www.cs.toronto.edu/~kriz/cifar.html

CIFAR100([root, fine_label, train, transform])

CIFAR100 image classification dataset from https://www.cs.toronto.edu/~kriz/cifar.html

ImageRecordDataset(filename[, flag, transform])

A dataset wrapping over a RecordIO file containing images.

ImageFolderDataset(root[, flag, transform])

A dataset for loading image files stored in a folder structure.

ImageListDataset([root, imglist, flag])

A dataset for loading image files specified by a list of entries.

class MNIST(root='/home/jenkins_slave/.mxnet/datasets/mnist', train=True, transform=None)[source]

Bases: mxnet.gluon.data.dataset._DownloadedDataset

MNIST handwritten digits dataset from http://yann.lecun.com/exdb/mnist

Each sample is an image (in 3D NDArray) with shape (28, 28, 1).

Parameters
  • root (str, default $MXNET_HOME/datasets/mnist) – Path to temp folder for storing data.

  • train (bool, default True) – Whether to load the training or testing set.

  • transform (function, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A user defined callback that transforms each sample. For example:

    transform=lambda data, label: (data.astype(np.float32)/255, label)
    

class FashionMNIST(root='/home/jenkins_slave/.mxnet/datasets/fashion-mnist', train=True, transform=None)[source]

Bases: mxnet.gluon.data.vision.datasets.MNIST

A dataset of Zalando’s article images consisting of fashion products, a drop-in replacement of the original MNIST dataset from https://github.com/zalandoresearch/fashion-mnist

Each sample is an image (in 3D NDArray) with shape (28, 28, 1).

Parameters
  • root (str, default $MXNET_HOME/datasets/fashion-mnist') – Path to temp folder for storing data.

  • train (bool, default True) – Whether to load the training or testing set.

  • transform (function, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A user defined callback that transforms each sample. For example:

    transform=lambda data, label: (data.astype(np.float32)/255, label)
    

class CIFAR10(root='/home/jenkins_slave/.mxnet/datasets/cifar10', train=True, transform=None)[source]

Bases: mxnet.gluon.data.dataset._DownloadedDataset

CIFAR10 image classification dataset from https://www.cs.toronto.edu/~kriz/cifar.html

Each sample is an image (in 3D NDArray) with shape (32, 32, 3).

Parameters
  • root (str, default $MXNET_HOME/datasets/cifar10) – Path to temp folder for storing data.

  • train (bool, default True) – Whether to load the training or testing set.

  • transform (function, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A user defined callback that transforms each sample. For example:

    transform=lambda data, label: (data.astype(np.float32)/255, label)
    

class CIFAR100(root='/home/jenkins_slave/.mxnet/datasets/cifar100', fine_label=False, train=True, transform=None)[source]

Bases: mxnet.gluon.data.vision.datasets.CIFAR10

CIFAR100 image classification dataset from https://www.cs.toronto.edu/~kriz/cifar.html

Each sample is an image (in 3D NDArray) with shape (32, 32, 3).

Parameters
  • root (str, default $MXNET_HOME/datasets/cifar100) – Path to temp folder for storing data.

  • fine_label (bool, default False) – Whether to load the fine-grained (100 classes) or coarse-grained (20 super-classes) labels.

  • train (bool, default True) – Whether to load the training or testing set.

  • transform (function, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A user defined callback that transforms each sample. For example:

    transform=lambda data, label: (data.astype(np.float32)/255, label)
    

class ImageRecordDataset(filename, flag=1, transform=None)[source]

Bases: mxnet.gluon.data.dataset.RecordFileDataset

A dataset wrapping over a RecordIO file containing images.

Each sample is an image and its corresponding label.

Parameters
  • filename (str) – Path to rec file.

  • flag ({0, 1}, default 1) – If 0, always convert images to greyscale. If 1, always convert images to colored (RGB).

  • transform (function, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A user defined callback that transforms each sample. For example:

    transform=lambda data, label: (data.astype(np.float32)/255, label)
    

class ImageFolderDataset(root, flag=1, transform=None)[source]

Bases: mxnet.gluon.data.dataset.Dataset

A dataset for loading image files stored in a folder structure.

like:

root/car/0001.jpg
root/car/xxxa.jpg
root/car/yyyb.jpg
root/bus/123.jpg
root/bus/023.jpg
root/bus/wwww.jpg
Parameters
  • root (str) – Path to root directory.

  • flag ({0, 1}, default 1) – If 0, always convert loaded images to greyscale (1 channel). If 1, always convert loaded images to colored (3 channels).

  • transform (callable, default None) –

    DEPRECATED FUNCTION ARGUMENTS. A function that takes data and label and transforms them:

    transform = lambda data, label: (data.astype(np.float32)/255, label)
    

synsets

List of class names. synsets[i] is the name for the integer label i

Type

list

items

List of all images in (filename, label) pairs.

Type

list of tuples

class ImageListDataset(root='.', imglist=None, flag=1)[source]

Bases: mxnet.gluon.data.dataset.Dataset

A dataset for loading image files specified by a list of entries.

like:

# if written to text file *.lst
0       0       root/car/0001.jpg
1       0       root/car/xxxa.jpg
2       0       root/car/yyyb.jpg
3       1       root/bus/123.jpg
4       1       root/bus/023.jpg
5       1       root/bus/wwww.jpg

# if as a pure list, each item is a list [imagelabel: float or list of float, imgpath]
[[0, root/car/0001.jpg]
 [0, root/car/xxxa.jpg]
 [0, root/car/yyyb.jpg]
 [1, root/bus/123.jpg]
 [1, root/bus/023.jpg]
 [1, root/bus/wwww.jpg]]
Parameters
  • root (str) – Path to root directory.

  • imglist (str or list) – Specify the path of imglist file or a list directly

  • flag ({0, 1}, default 1) – If 0, always convert loaded images to greyscale (1 channel). If 1, always convert loaded images to colored (3 channels).

items

List of all images in (filename, label) pairs.

Type

list of tuples