Download - module for downloading and unpacking files

Download from Google Drive

dlutils.download.from_google_drive(google_drive_fileid, directory='.', file_name=None, extract_targz=False, extract_gz=False, extract_zip=False)[source]

Downloads file from Google Drive.

Given the file ID, file is downloaded from Google Drive and optionally it can be unpacked after downloading completes.

Note

You need to share the file as Anyone who has the link can access. No sign-in required.. You can find the file ID in the link:

https://drive.google.com/file/d/ 0B3kP5zWXwFm_OUpQbDFqY2dXNGs /view?usp=sharing

Parameters
  • google_drive_fileid (str) – file ID.

  • directory (str) – Directory where to save the file

  • file_name (str, optional) – If not None, this will overwrite the file name, otherwise it will use the filename returned from http request. Defaults to None.

  • extract_targz (bool) – Extract tar.gz archive. Defaults to False.

  • extract_gz (bool) – Decompress gz compressed file. Defaults to False.

  • extract_zip (bool) – Extract zip archive. Defaults to False.

Example

dlutils.download.from_google_drive(directory="data/", google_drive_fileid="0B3kP5zWXwFm_OUpQbDFqY2dXNGs")

Download from URL

dlutils.download.from_url(url, directory='.', file_name=None, extract_targz=False, extract_gz=False, extract_zip=False)[source]

Downloads file from specified URL.

Optionally it can be unpacked after downloading completes.

Parameters
  • url (str) – file URL.

  • directory (str) – Directory where to save the file

  • file_name (str, optional) – If not None, this will overwrite the file name, otherwise it will use the filename returned from http request. Defaults to None.

  • extract_targz (bool) – Extract tar.gz archive. Defaults to False.

  • extract_gz (bool) – Decompress gz compressed file. Defaults to False.

  • extract_zip (bool) – Extract zip archive. Defaults to False.

Example

dlutils.download.from_url("http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz", directory, extract_gz=True)

Download MNIST

dlutils.download.mnist(directory='mnist')[source]

Downloads MNIST Dataset.

Parameters

directory (str) – Directory where to save the files

Download Fashion-MNIST

dlutils.download.fashion_mnist(directory='fashion-mnist')[source]

Downloads Fashion-MNIST Dataset.

Parameters

directory (str) – Directory where to save the files

Download CIFAR-10

dlutils.download.cifar10(directory='cifar10')[source]

Downloads CIFAR10 Dataset.

Parameters

directory (str) – Directory where to save the files

Download CIFAR-100

dlutils.download.cifar100(directory='cifar100')[source]

Downloads CIFAR100 Dataset.

Parameters

directory (str) – Directory where to save the files