edflow.data.believers.meta_loaders module¶
Summary¶
Functions:
Turns an abstract category label into a readable label. |
|
|
|
|
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 isnp.uint8
and all values are integers between 0 and 255.0->1
: Datatype isnp.float32
and all values are floats between 0 and 1.-1->1
: Datatype isnp.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 is0
,{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 theindex
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 alist
ordict
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
category –
categories[index]
- Return type
object