albumentations.core.label_manager
Module for managing and transforming label data during augmentation. This module provides utilities for encoding, decoding, and tracking metadata for labels during the augmentation process. It includes classes for managing label transformations, preserving data types, and ensuring consistent handling of categorical, numerical, and mixed label types. The module supports automatic encoding of string labels to numerical values and restoration of original data types after processing.
Members
- classLabelEncoder
- classLabelManager
- classLabelMetadata
- functioncustom_sort
LabelEncoderclass
LabelEncoder()
Encodes labels into integer indices. This class handles the conversion between original label values and their numerical representations. It supports both numerical and categorical labels.
LabelManagerclass
LabelManager()
Manages label encoding and decoding across multiple data fields. This class handles the encoding, decoding, and type management for label fields. It maintains metadata about each field to ensure proper conversion between original and encoded representations.
LabelMetadataclass
LabelMetadata(
input_type: type,
is_numerical: bool,
dtype: np.dtype | None = None,
encoder: LabelEncoder | None = None
)
Stores metadata about a label field.
Parameters
Name | Type | Default | Description |
---|---|---|---|
input_type | type | - | - |
is_numerical | bool | - | - |
dtype | One of:
| None | - |
encoder | One of:
| None | - |
custom_sortfunction
custom_sort(
item: Any
)
Sort items by type then value for consistent label ordering. This function is used to sort labels in a consistent order, prioritizing numerical values before string values. All numerical values are given priority 0, while string values are given priority 1, ensuring numerical values are sorted first.
Parameters
Name | Type | Default | Description |
---|---|---|---|
item | Any | - | Item to be sorted, can be either a numeric value or any other type. |
Returns
- tuple[int, Real | str]: A tuple with sort priority (0 for numbers, 1 for others)