Core API (volumentations.core)¶
Composition¶
-
class
volumentations.core.composition.
Compose
(transforms, additional_targets=None, p=1.0)[source]¶ Compose transforms and handle all transformations regrading bounding boxes.
- Parameters
transforms (list) – list of transformations to compose.
additional_targets (dict) – Dict with keys - new target name, values - old target name. ex: {‘image2’: ‘image’}
p (float) – probability of applying all list of transforms. Default: 1.0.
Transforms interface¶
-
volumentations.core.transforms_interface.
to_tuple
(param, low=None, bias=None)[source]¶ Convert input argument to min-max tuple
- Parameters
param (scalar, tuple or list of 2+ elements) – Input value. If value is scalar, return value would be (offset - value, offset + value). If value is tuple, return value would be value + offset (broadcasted).
low – Second element of tuple can be passed as optional argument
bias – An offset factor added to each element
Serialization¶
-
volumentations.core.serialization.
to_dict
(transform, on_not_implemented_error='raise')[source]¶ Take a transform pipeline and convert it to a serializable representation that uses only standard python data types: dictionaries, lists, strings, integers, and floats.
- Parameters
transform (object) – A transform that should be serialized. If the transform doesn’t implement the to_dict method and on_not_implemented_error equals to ‘raise’ then NotImplementedError is raised. If on_not_implemented_error equals to ‘warn’ then NotImplementedError will be ignored but no transform parameters will be serialized.
-
volumentations.core.serialization.
from_dict
(transform_dict, lambda_transforms=None)[source]¶ - Parameters
transform (dict) – A dictionary with serialized transform pipeline.
lambda_transforms (dict) – A dictionary that contains lambda transforms, that is instances of the Lambda class. This dictionary is required when you are restoring a pipeline that contains lambda transforms. Keys in that dictionary should be named same as name arguments in respective lambda transforms from a serialized pipeline.
-
volumentations.core.serialization.
save
(transform, filepath, data_format='json', on_not_implemented_error='raise')[source]¶ Take a transform pipeline, serialize it and save a serialized version to a file using either json or yaml format.
- Parameters
transform (obj) – Transform to serialize.
filepath (str) – Filepath to write to.
data_format (str) – Serialization format. Should be either json or ‘yaml’.
on_not_implemented_error (str) – Parameter that describes what to do if a transform doesn’t implement the to_dict method. If ‘raise’ then NotImplementedError is raised, if warn then the exception will be ignored and no transform arguments will be saved.
-
volumentations.core.serialization.
load
(filepath, data_format='json', lambda_transforms=None)[source]¶ Load a serialized pipeline from a json or yaml file and construct a transform pipeline.
- Parameters
transform (obj) – Transform to serialize.
filepath (str) – Filepath to read from.
data_format (str) – Serialization format. Should be either json or ‘yaml’.
lambda_transforms (dict) – A dictionary that contains lambda transforms, that is instances of the Lambda class. This dictionary is required when you are restoring a pipeline that contains lambda transforms. Keys in that dictionary should be named same as name arguments in respective lambda transforms from a serialized pipeline.