edflow.data.believers.meta_loaders module

Summary

Functions:

category

Turns an abstract category label into a readable label.

image_loader

param path

Where to finde the image.

numpy_loader

param path

Where to finde the array.

Reference

edflow.data.believers.meta_loaders.image_loader(path, root='', support='0->255', resize_to=None)[source]
Parameters
  • path (str) – Where to finde the image.

  • root (str) – Root path, at which the suuplied path starts. E.g. if all paths supplied to this function are relative to /export/scratch/you_are_great/dataset, this path would be root.

  • support (str) –

    Defines the support and data type of the loaded image. Must be one of
    • 0->255: The PIL default. Datatype is np.uint8 and all values are integers between 0 and 255.

    • 0->1: Datatype is np.float32 and all values are floats between 0 and 1.

    • -1->1: Datatype is np.float32 and all values are floats between -1 and 1.

  • resize_to (list) – If not None, the loaded image will be resized to these dimensions. Must be a list of two integers or a single integer, which is interpreted as list of two integers with same value.

Returns

im – An image loaded using PIL.Image and adjusted to the range as specified.

Return type

np.array

edflow.data.believers.meta_loaders.numpy_loader(path, root='')[source]
Parameters

path (str) – Where to finde the array.

Returns

arr – An array loaded using np.load

Return type

np.array

edflow.data.believers.meta_loaders.category(index, categories)[source]

Turns an abstract category label into a readable label.

Example:

Your dataset has the label pid which has integer entries like [0, 0, 0, ..., 2, 2] between 0 and 3.

Inside the dataset’s meta.yaml you define

# meta.yaml
# ...
loaders:
    pid: category
loader_kwargs:
    pid:
        categories: ['besser', 'pesser', 'Mimo Tilbich']

Now examples will be annotated with {pid: 'besser'} if the pid is 0, {pid: 'pesser'} if pid is 1 or {pid: 'Mimo Tilbich'} if the pid is 2.

Note that categories can be anything that implements a __getitem__ method. You simply need to take care, that it understands the index value it is passed by this loader function.

Parameters
  • index (int, Hashable) – Some value that will be passed to categories’s __getitem__() method. I.e. categories can be a list or dict or whatever you want!

  • categories (list, dict, object with __getitem__ method) – Defines the categories you have in you dataset. Will be accessed like categories[index]

Returns

categorycategories[index]

Return type

object