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 applytransform
.- Parameters
root (
Optional
[str
]) – Optional root directory if the file is a relative path.**read_image_kwargs – Optional parameters passed to
pystiche.image.read_image()
.
- Return type
- class pystiche.data.LocalImageCollection(images)¶
- read(root=None, **read_image_kwargs)¶
Read the images from file.
- 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 topystiche.home()
.overwrite (
bool
) – Overwrites files if they already exists or the MD5 checksum does not match. Defaults toFalse
.
- Return type
- static generate_file(url, title, author)¶
Generate a filename from the supplied information from the following scheme:
If
title
andauthor
areNone
, the ending ofurl
is used.If one of
title
orauthor
is notNone
, it is used as filename where spaces are replaced by underscores.If
title
andauthor
are not None, the filename is generated as above separating both path with double underscores.
- read(root=None, download=None, overwrite=False, **read_image_kwargs)¶
Read the image from file with
pystiche.image.read_image()
. If available thetransform
is applied afterwards.- Parameters
root (
Optional
[str
]) – Optional root directory if the file is a relative path. Defaults topystiche.home()
.download (
Optional
[bool
]) – IfTrue
, downloads the image first. Defaults toFalse
if the file already exists and the MD5 checksum is not known. Otherwise defaults toTrue
.overwrite (
bool
) – If downloaded, overwrites files if they already exists or the MD5 checksum does not match. Defaults toFalse
.**read_image_kwargs – Optional parameters passed to
pystiche.image.read_image()
.
- Return type
- 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 topystiche.home()
.overwrite (
bool
) – Overwrites files if they already exists or the MD5 checksum does not match. Defaults toFalse
.
- Return type
- 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 topystiche.home()
.download (
Optional
[bool
]) – IfTrue
, downloads the image first. Defaults toFalse
if the file already exists and the MD5 checksum is not known. Otherwise defaults toTrue
.overwrite (
bool
) – If downloaded, overwrites files if they already exists or the MD5 checksum does not match. Defaults toFalse
.**read_image_kwargs – Optional parameters passed to
pystiche.image.read_image()
.
- Return type
- Returns
Dictionary with the name image pairs.