datasets.rst 3.01 KB
Newer Older
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
1
2
torchvision.datasets
====================
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
3
4
5
6

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`
7
which can load multiple samples parallelly using ``torch.multiprocessing`` workers.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
8
For example: ::
9

Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
10
    imagenet_data = torchvision.datasets.ImageFolder('path/to/imagenet_root/')
11
    data_loader = torch.utils.data.DataLoader(imagenet_data,
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
12
13
14
15
16
17
18
19
20
21
22
23
24
                                              batch_size=4,
                                              shuffle=True,
                                              num_workers=args.nThreads)

The following datasets are available:

.. contents:: Datasets
    :local:

All the datasets have almost similar API. They all have two common arguments:
``transform`` and  ``target_transform`` to transform the input and target respectively.


25
.. currentmodule:: torchvision.datasets
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
26
27
28
29
30
31
32


MNIST
~~~~~

.. autoclass:: MNIST

33
34
35
36
37
Fashion-MNIST
~~~~~~~~~~~~~

.. autoclass:: FashionMNIST

hysts's avatar
hysts committed
38
39
40
41
42
KMNIST
~~~~~~~~~~~~~

.. autoclass:: KMNIST

43
44
45
46
47
EMNIST
~~~~~~

.. autoclass:: EMNIST

48
49
50
51
52
FakeData
~~~~~~~~

.. autoclass:: FakeData

Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
COCO
~~~~

.. note ::
    These require the `COCO API to be installed`_

.. _COCO API to be installed: https://github.com/pdollar/coco/tree/master/PythonAPI


Captions
^^^^^^^^

.. autoclass:: CocoCaptions
  :members: __getitem__
  :special-members:


Detection
^^^^^^^^^

.. autoclass:: CocoDetection
  :members: __getitem__
  :special-members:

LSUN
~~~~

.. autoclass:: LSUN
  :members: __getitem__
  :special-members:

ImageFolder
~~~~~~~~~~~

.. autoclass:: ImageFolder
  :members: __getitem__
  :special-members:

91
92
93
94
95
96
97
98
DatasetFolder
~~~~~~~~~~~~~

.. autoclass:: DatasetFolder
  :members: __getitem__
  :special-members:


Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
99
100
101
102
103
104
105
106
107

Imagenet-12
~~~~~~~~~~~

This should simply be implemented with an ``ImageFolder`` dataset.
The data is preprocessed `as described
here <https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md#download-the-imagenet-dataset>`__

`Here is an
108
example <https://github.com/pytorch/examples/blob/e0d33a69bec3eb4096c265451dbb85975eb961ea/imagenet/main.py#L113-L126>`__.
Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
109
110
111
112
113
114
115
116

CIFAR
~~~~~

.. autoclass:: CIFAR10
  :members: __getitem__
  :special-members:

jvmancuso's avatar
jvmancuso committed
117
118
.. autoclass:: CIFAR100

Sasank Chilamkurthy's avatar
Sasank Chilamkurthy committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
STL10
~~~~~


.. autoclass:: STL10
  :members: __getitem__
  :special-members:

SVHN
~~~~~


.. autoclass:: SVHN
  :members: __getitem__
  :special-members:

PhotoTour
~~~~~~~~~


.. autoclass:: PhotoTour
  :members: __getitem__
  :special-members:
142
143
144
145
146
147
148
149
150

SBU
~~~


.. autoclass:: SBU
  :members: __getitem__
  :special-members:

151
152
153
154
155
156
157
158
159
160
161
Flickr
~~~~~~


.. autoclass:: Flickr8k
  :members: __getitem__
  :special-members:

.. autoclass:: Flickr30k
  :members: __getitem__
  :special-members:
162
163
164
165
166
167
168
169
170
171
172
173

VOC
~~~~~~


.. autoclass:: VOCSegmentation
  :members: __getitem__
  :special-members:

.. autoclass:: VOCDetection
  :members: __getitem__
  :special-members:
Michael Kösel's avatar
Michael Kösel committed
174
175
176
177
178
179
180
181
182
183

Cityscapes
~~~~~~~~~~

.. note ::
    Requires Cityscape to be downloaded.

.. autoclass:: Cityscapes
  :members: __getitem__
  :special-members: