forked from fastai/fastai
/
datasets.html
367 lines (247 loc) · 17.9 KB
/
datasets.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
---
keywords: fastai
sidebar: home_sidebar
---
<div class="container" id="notebook-container">
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="datasets">datasets<a class="anchor-link" href="#datasets">¶</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>This module has the necessary functions to be able to download several useful datasets that we might be interested in using in our models.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h2 id="URLs" class="doc_header"><code>class</code> <code>URLs</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L8" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#URLs-pytest" style="float:right; padding-right:10px">[test]</a></h2><blockquote><p><code>URLs</code>()</p>
</blockquote>
<div class="collapse" id="URLs-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#URLs-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>URLs</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Global constants for dataset and model URLs.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>This contains all the datasets' and models' URLs, and some classmethods to help use them - you don't create objects of this class. The supported datasets are (with their calling name): <code>S3_NLP</code>, <code>S3_COCO</code>, <code>MNIST_SAMPLE</code>, <code>MNIST_TINY</code>, <code>IMDB_SAMPLE</code>, <code>ADULT_SAMPLE</code>, <code>ML_SAMPLE</code>, <code>PLANET_SAMPLE</code>, <code>CIFAR</code>, <code>PETS</code>, <code>MNIST</code>. To get details on the datasets you can see the <a href="http://course.fast.ai/datasets">fast.ai datasets webpage</a>. Datasets with SAMPLE in their name are subsets of the original datasets. In the case of MNIST, we also have a TINY dataset which is even smaller than MNIST_SAMPLE.</p>
<p>Models is now limited to <code>WT103</code> but you can expect more in the future!</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">URLs</span><span class="o">.</span><span class="n">MNIST_SAMPLE</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_text output_subarea output_execute_result">
<pre>'http://files.fast.ai/data/examples/mnist_sample'</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Downloading-Data">Downloading Data<a class="anchor-link" href="#Downloading-Data">¶</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>For the rest of the datasets you will need to download them with <a href="/datasets.html#untar_data"><code>untar_data</code></a> or <a href="/datasets.html#download_data"><code>download_data</code></a>. <a href="/datasets.html#untar_data"><code>untar_data</code></a> will decompress the data file and download it while <a href="/datasets.html#download_data"><code>download_data</code></a> will just download and save the compressed file in <code>.tgz</code> format.</p>
<p>By default, data will be downloaded to <code>~/.fastai/data</code> folder.<br>
Configure the default <code>data_path</code> by editing <code>~/.fastai/config.yml</code>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="untar_data" class="doc_header"><code>untar_data</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L204" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#untar_data-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>untar_data</code>(<strong><code>url</code></strong>:<code>str</code>, <strong><code>fname</code></strong>:<code>PathOrStr</code>=<strong><em><code>None</code></em></strong>, <strong><code>dest</code></strong>:<code>PathOrStr</code>=<strong><em><code>None</code></em></strong>, <strong><code>data</code></strong>=<strong><em><code>True</code></em></strong>, <strong><code>force_download</code></strong>=<strong><em><code>False</code></em></strong>) → <code>Path</code></p>
</blockquote>
<div class="collapse" id="untar_data-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#untar_data-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>untar_data</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Download <code>url</code> to <code>fname</code> if it doesn't exist, and un-tgz to folder <code>dest</code>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">untar_data</span><span class="p">(</span><span class="n">URLs</span><span class="o">.</span><span class="n">PLANET_SAMPLE</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_text output_subarea output_execute_result">
<pre>PosixPath('/home/ubuntu/.fastai/data/planet_sample')</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="download_data" class="doc_header"><code>download_data</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L189" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#download_data-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>download_data</code>(<strong><code>url</code></strong>:<code>str</code>, <strong><code>fname</code></strong>:<code>PathOrStr</code>=<strong><em><code>None</code></em></strong>, <strong><code>data</code></strong>:<code>bool</code>=<strong><em><code>True</code></em></strong>) → <code>Path</code></p>
</blockquote>
<div class="collapse" id="download_data-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#download_data-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>download_data</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Download <code>url</code> to destination <code>fname</code>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Note: If the data file already exists in a <code>data</code> directory inside the notebook, that data file will be used instead of <code>~/.fasta/data</code>. Paths are resolved by calling the function <a href="/datasets.html#datapath4file"><code>datapath4file</code></a> - which checks if data exists locally (<code>data/</code>) first, before downloading to <code>~/.fastai/data</code> home directory.</p>
<p>Example:</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">download_data</span><span class="p">(</span><span class="n">URLs</span><span class="o">.</span><span class="n">PLANET_SAMPLE</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_text output_subarea output_execute_result">
<pre>PosixPath('/home/ubuntu/.fastai/data/planet_sample.tgz')</pre>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="datapath4file" class="doc_header"><code>datapath4file</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L183" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#datapath4file-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>datapath4file</code>(<strong><code>filename</code></strong>)</p>
</blockquote>
<div class="collapse" id="datapath4file-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#datapath4file-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>datapath4file</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Return data path to <code>filename</code>, checking locally first then in the config file.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>All the downloading functions use this to decide where to put the tgz and expanded folder. If <code>filename</code> already exists in a <code>data</code> directory in the same place as the calling notebook/script, that is used as the parent directly, otherwise <code>~/.fastai/config.yml</code> is read to see what path to use, which defaults to <code>~/.fastai/data</code> is used. To override this default, simply modify the value in your <code>~/.fastai/config.yml</code>:</p>
<pre><code>data_path: ~/.fastai/data</code></pre>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="url2path" class="doc_header"><code>url2path</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L170" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#url2path-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>url2path</code>(<strong><code>url</code></strong>, <strong><code>data</code></strong>=<strong><em><code>True</code></em></strong>)</p>
</blockquote>
<div class="collapse" id="url2path-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#url2path-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>url2path</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Change <code>url</code> to a path.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h2 id="Config" class="doc_header"><code>class</code> <code>Config</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L122" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#Config-pytest" style="float:right; padding-right:10px">[test]</a></h2><blockquote><p><code>Config</code>()</p>
</blockquote>
<div class="collapse" id="Config-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#Config-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>Tests found for <code>Config</code>:</p><ul><li><code>pytest -sv tests/test_datasets.py::test_creates_config</code> <a href="https://github.com/fastai/fastai/blob/master/tests/test_datasets.py#L13" class="source_link" style="float:right">[source]</a></li></ul><p>To run tests please refer to this <a href="/dev/test.html#quick-guide">guide</a>.</p></div></div><p>Creates a default config file at <code>~/.fastai/config.yml</code></p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You probably won't need to use this yourself - it's used by <code>URLs.datapath4file</code>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="Config.get_path" class="doc_header"><code>get_path</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L135" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#Config-get_path-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>get_path</code>(<strong><code>path</code></strong>)</p>
</blockquote>
<div class="collapse" id="Config-get_path-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#Config-get_path-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>get_path</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Get the <code>path</code> in the config file.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Get the key corresponding to <code>path</code> in the <a href="/datasets.html#Config"><code>Config</code></a>.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="Config.data_path" class="doc_header"><code>data_path</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L140" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#Config-data_path-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>data_path</code>()</p>
</blockquote>
<div class="collapse" id="Config-data_path-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#Config-data_path-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>data_path</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Get the path to data in the config file.</p>
</div>
</div>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Get the <code>Path</code> where the data is stored.</p>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="output_markdown rendered_html output_subarea ">
<h4 id="Config.model_path" class="doc_header"><code>model_path</code><a href="https://github.com/fastai/fastai/blob/master/fastai/datasets.py#L145" class="source_link" style="float:right">[source]</a><a class="source_link" data-toggle="collapse" data-target="#Config-model_path-pytest" style="float:right; padding-right:10px">[test]</a></h4><blockquote><p><code>model_path</code>()</p>
</blockquote>
<div class="collapse" id="Config-model_path-pytest"><div class="card card-body pytest_card"><a type="button" data-toggle="collapse" data-target="#Config-model_path-pytest" class="close" aria-label="Close"><span aria-hidden="true">×</span></a><p>No tests found for <code>model_path</code>. To contribute a test please refer to <a href="/dev/test.html">this guide</a> and <a href="https://forums.fast.ai/t/improving-expanding-functional-tests/32929">this discussion</a>.</p></div></div><p>Get the path to fastai pretrained models in the config file.</p>
</div>
</div>
</div>
</div>
</div>
</div>