datasets.rst 2.01 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
    EMNIST
    FakeData
    FashionMNIST
Philip Meier's avatar
Philip Meier committed
45
    FER2013
46
47
    Flickr8k
    Flickr30k
48
    FlyingChairs
49
    FlyingThings3D
Joao Gomes's avatar
Joao Gomes committed
50
    Food101
Sumukh Aithal's avatar
Sumukh Aithal committed
51
    GTSRB
52
    HD1K
53
54
55
56
57
    HMDB51
    ImageNet
    INaturalist
    Kinetics400
    Kitti
58
    KittiFlow
59
60
61
62
63
64
    KMNIST
    LFWPeople
    LFWPairs
    LSUN
    MNIST
    Omniglot
Philip Meier's avatar
Philip Meier committed
65
    OxfordIIITPet
66
67
68
69
70
71
    PhotoTour
    Places365
    QMNIST
    SBDataset
    SBU
    SEMEION
72
    Sintel
73
74
75
76
77
78
79
    STL10
    SVHN
    UCF101
    USPS
    VOCSegmentation
    VOCDetection
    WIDERFace
80
81
82
83
84
85

.. _base_classes_datasets:

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

86
87
88
.. autosummary::
    :toctree: generated/
    :template: class.rst
89

90
91
92
    DatasetFolder
    ImageFolder
    VisionDataset