stylish.filesystem

stylish.filesystem.create_log_path(style_path, relative_path=None)[source]

Return Tensorflow log path.

Example:

>>> create_log_path("/path/to/Foo.jpg")
"/tmp/stylish/log/foo-2019-09-14_15:12:11/"

>>> create_log_path("/path/to/Foo.jpg", relative_path="/path")
"/path/stylish/log/foo-2019-09-14_15:12:11/"
Parameters:
  • style_path – path to an image from which the style features will be extracted.
  • relative_path – Path to a folder to generate logs into. The temporary folder is used otherwise.
Returns:

Path to save Tensorflow logs.

stylish.filesystem.load_image(path, image_size=None)[source]

Return 3-D Numpy array from image path.

Parameters:
  • path – path to image file to load.
  • image_size – targeted size of the image matrix loaded. By default, the image will not be resized.
Returns:

3-D Numpy array representing the image loaded.

stylish.filesystem.save_image(image, path)[source]

Save image_matrix to path.

Parameters:
  • image – 3-D Numpy array representing the image to save.
  • path – path to image file to save image into.
Returns:

None

stylish.filesystem.fetch_images(path, limit=None)[source]

Return list of image paths from path.

Parameters:
  • path – path to the directory containing all images to fetch.
  • limit – maximum number of files to fetch from path. By default, all files are fetched.
Returns:

list of image file path.

stylish.filesystem.ensure_directory(path)[source]

Ensure directory exists at path.

Parameters:path – directory path.
Returns:None
stylish.filesystem.sanitise_value(value, substitution_character='_', case_sensitive=True)[source]

Return value suitable for use with filesystem.

Parameters:
  • value – string value to sanitise.
  • substitution_character – string character to replace awkward characters with. Default is “_”.
  • case_sensitive – indicate whether sanitised value should be kept with original case. Otherwise, the sanitised value will be return in lowercase. By default, the original case is preserved.
Returns:

sanitised value.