datasets.rst 1.97 KB
Newer Older
1
2
3
4
5
6
7
8
Datasets
========

Torchvision provides many built-in datasets in the ``torchvision.datasets``
module, as well as utility classes for building your own datasets.

Built-in datasets
~~~~~~~~~~~~~~~~~
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
9
10
11
12

All datasets are subclasses of :class:`torch.utils.data.Dataset`
i.e, they have ``__getitem__`` and ``__len__`` methods implemented.
Hence, they can all be passed to a :class:`torch.utils.data.DataLoader`
13
which can load multiple samples in parallel using ``torch.multiprocessing`` workers.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
14
For example: ::
15

16
    imagenet_data = torchvision.datasets.ImageNet('path/to/imagenet_root/')
17
    data_loader = torch.utils.data.DataLoader(imagenet_data,
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
18
19
20
21
                                              batch_size=4,
                                              shuffle=True,
                                              num_workers=args.nThreads)

22
.. currentmodule:: torchvision.datasets
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
23
24
25

All the datasets have almost similar API. They all have two common arguments:
``transform`` and  ``target_transform`` to transform the input and target respectively.
26
You can also create your own datasets using the provided :ref:`base classes <base_classes_datasets>`.
27

28

29
30
31
32
33
34
35
36
37
38
39
40
.. autosummary::
    :toctree: generated/
    :template: class_dataset.rst

    Caltech101
    Caltech256
    CelebA
    CIFAR10
    CIFAR100
    Cityscapes
    CocoCaptions
    CocoDetection
Philip Meier's avatar
Philip Meier committed
41
    DTD
42
43
44
45
46
    EMNIST
    FakeData
    FashionMNIST
    Flickr8k
    Flickr30k
47
    FlyingChairs
48
    FlyingThings3D
Joao Gomes's avatar
Joao Gomes committed
49
    Food101
50
    HD1K
51
52
53
54
55
    HMDB51
    ImageNet
    INaturalist
    Kinetics400
    Kitti
56
    KittiFlow
57
58
59
60
61
62
63
64
65
66
67
68
    KMNIST
    LFWPeople
    LFWPairs
    LSUN
    MNIST
    Omniglot
    PhotoTour
    Places365
    QMNIST
    SBDataset
    SBU
    SEMEION
69
    Sintel
70
71
72
73
74
75
76
    STL10
    SVHN
    UCF101
    USPS
    VOCSegmentation
    VOCDetection
    WIDERFace
77
78
79
80
81
82

.. _base_classes_datasets:

Base classes for custom datasets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

83
84
85
.. autosummary::
    :toctree: generated/
    :template: class.rst
86

87
88
89
    DatasetFolder
    ImageFolder
    VisionDataset