pystiche.data

class pystiche.data.LocalImage(file, collect_local_guides=True, guides=None, transform=None, note=None)
read(root=None, **read_image_kwargs)

Read the image from file with pystiche.image.read_image() and optionally apply transform.

Parameters
Return type

Tensor

class pystiche.data.LocalImageCollection(images)
read(root=None, **read_image_kwargs)

Read the images from file.

Parameters
Return type

Dict[str, Tensor]

Returns

Dictionary with the name image pairs.

class pystiche.data.DownloadableImage(url, title=None, author=None, date=None, license=None, md5=None, file=None, guides=None, prefix_guide_files=True, transform=None, note=None)
download(root=None, overwrite=False)

Download the image and if applicable the guides from their URL. If the correct MD5 checksum is known, it is verified first. If it checks out the file not re-downloaded.

Parameters
  • root (Optional[str]) – Optional root directory for the download if the file is a relative path. Defaults to pystiche.home().

  • overwrite (bool) – Overwrites files if they already exists or the MD5 checksum does not match. Defaults to False.

Return type

None

static generate_file(url, title, author)

Generate a filename from the supplied information from the following scheme:

  • If title and author are None, the ending of url is used.

  • If one of title or author is not None, it is used as filename where spaces are replaced by underscores.

  • If title and author are not None, the filename is generated as above separating both path with double underscores.

Parameters
  • url (str) – URL to the image.

  • title (Optional[str]) – Optional title of the image.

  • author (Optional[str]) – Optional author of the image

Return type

str

read(root=None, download=None, overwrite=False, **read_image_kwargs)

Read the image from file with pystiche.image.read_image(). If available the transform is applied afterwards.

Parameters
  • root (Optional[str]) – Optional root directory if the file is a relative path. Defaults to pystiche.home().

  • download (Optional[bool]) – If True, downloads the image first. Defaults to False if the file already exists and the MD5 checksum is not known. Otherwise defaults to True.

  • overwrite (bool) – If downloaded, overwrites files if they already exists or the MD5 checksum does not match. Defaults to False.

  • **read_image_kwargs – Optional parameters passed to pystiche.image.read_image().

Return type

Tensor

class pystiche.data.DownloadableImageCollection(images)
download(root=None, overwrite=False)

Download all images and if applicable their guides from their URLs. See pystiche.data.DownloadableImage.download() for details.

Parameters
  • root (Optional[str]) – Optional root directory for the download if the file is a relative path. Defaults to pystiche.home().

  • overwrite (bool) – Overwrites files if they already exists or the MD5 checksum does not match. Defaults to False.

Return type

None

read(root=None, download=None, overwrite=False, **read_image_kwargs)

Read the images from file. See pystiche.data.DownloadableImage.read() for details.

Parameters
  • root (Optional[str]) – Optional root directory if the file is a relative path. Defaults to pystiche.home().

  • download (Optional[bool]) – If True, downloads the image first. Defaults to False if the file already exists and the MD5 checksum is not known. Otherwise defaults to True.

  • overwrite (bool) – If downloaded, overwrites files if they already exists or the MD5 checksum does not match. Defaults to False.

  • **read_image_kwargs – Optional parameters passed to pystiche.image.read_image().

Return type

Dict[str, Tensor]

Returns

Dictionary with the name image pairs.