{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module has the necessary functions to be able to download several useful datasets that we might be interested in using in our models." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.datasets import * \n", "from fastai.datasets import Config\n", "from pathlib import Path" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "
class
URLs
[source][test]URLs
()\n",
"\n",
"untar_data
[source][test]untar_data
(**`url`**:`str`, **`fname`**:`PathOrStr`=***`None`***, **`dest`**:`PathOrStr`=***`None`***, **`data`**=***`True`***, **`force_download`**=***`False`***) → `Path`\n",
"\n",
"Tests found for untar_data
:
pytest -sv tests/test_datasets.py::test_load_config
[source]pytest -sv tests/test_datasets.py::test_user_config
[source]pytest -sv tests/test_vision_data.py::test_trunc_download
[source]Some other tests where untar_data
is used:
pytest -sv tests/test_datasets.py::test_user_config
[source]To run tests please refer to this guide.
download_data
[source][test]download_data
(**`url`**:`str`, **`fname`**:`PathOrStr`=***`None`***, **`data`**:`bool`=***`True`***, **`ext`**:`str`=***`'.tgz'`***) → `Path`\n",
"\n",
"data
directory inside the notebook, that data file will be used instead of the one present in the folder specified in `config.yml`. `config.yml` is located in the directory specified in optional environment variable `FASTAI_HOME` (defaults to `~/.fastai/`). Paths are resolved by calling the function [`datapath4file`](/datasets.html#datapath4file) - which checks if data exists locally (`data/`) first, before downloading to the folder specified in `config.yml`.\n",
"\n",
"Example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PosixPath('/home/ubuntu/.fastai/data/planet_sample.tgz')"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"download_data(URLs.PLANET_SAMPLE)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide_input": true
},
"outputs": [
{
"data": {
"text/markdown": [
"datapath4file
[source][test]datapath4file
(**`filename`**, **`ext`**:`str`=***`'.tgz'`***, **`archive`**=***`True`***)\n",
"\n",
"data
directory in the same place as the calling notebook/script, that is used as the parent directly, otherwise `config.yml` is read to see what path to use, which defaults to ~/.fastai/data
is used. To override this default, simply modify the value in your `config.yml`:\n",
"\n",
" data_archive_path: ~/.fastai/data\n",
" data_path: ~/.fastai/data\n",
"\n",
"`config.yml` is located in the directory specified in optional environment variable `FASTAI_HOME` (defaults to `~/.fastai/`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"hide_input": true
},
"outputs": [
{
"data": {
"text/markdown": [
"url2path
[source][test]url2path
(**`url`**, **`data`**=***`True`***, **`ext`**:`str`=***`'.tgz'`***)\n",
"\n",
"class
Config
[source][test]Config
()\n",
"\n",
"Tests found for Config
:
pytest -sv tests/test_datasets.py::test_creates_config
[source]pytest -sv tests/test_datasets.py::test_default_config
[source]pytest -sv tests/test_datasets.py::test_load_config
[source]pytest -sv tests/test_datasets.py::test_user_config
[source]Some other tests where Config
is used:
pytest -sv tests/test_datasets.py::test_user_config
[source]To run tests please refer to this guide.
get_path
[source][test]get_path
(**`path`**)\n",
"\n",
"No tests found for get_path
. To contribute a test please refer to this guide and this discussion.
data_path
[source][test]data_path
()\n",
"\n",
"No tests found for data_path
. To contribute a test please refer to this guide and this discussion.
model_path
[source][test]model_path
()\n",
"\n",
"No tests found for model_path
. To contribute a test please refer to this guide and this discussion.
create
[source][test]create
(**`fpath`**)\n",
"\n",
"No tests found for create
. To contribute a test please refer to this guide and this discussion.
url2name
[source][test]url2name
(**`url`**)\n",
"\n",
"No tests found for url2name
. To contribute a test please refer to this guide and this discussion.
get_key
[source][test]get_key
(**`key`**)\n",
"\n",
"No tests found for get_key
. To contribute a test please refer to this guide and this discussion.
get
[source][test]get
(**`fpath`**=***`None`***, **`create_missing`**=***`True`***)\n",
"\n",
"