Skip to content

NormalizePreprocessor

Bases: DataPreprocessor

Data preprocessor that applies min-max normalization

Examples:

Assume the data is a 3-channel image of data type uint8.

You can scale the data to a range of 0 to 1 by normalizing the data.

>>> normalize_preprocessor = NormalizePreprocessor(
...     min_values=[0.] * 3,
...     max_values=[255.] * 3,
... )
>>> preprocessed_data = normalize_preprocessor(data)
PARAMETER DESCRIPTION
min_values

minimum values of the data (per channel)

TYPE: list[float]

max_values

maximum values of the data (per channel)

TYPE: list[float]

from_config classmethod

Creates a normalize preprocessor from the configuration.

PARAMETER DESCRIPTION
config

configuration

TYPE: NormalizePreprocessorConfig

RETURNS DESCRIPTION
NormalizePreprocessor

normalize preprocessor

__call__

Preprocesses the data by applying min-max normalization.

PARAMETER DESCRIPTION
data

data

TYPE: npt.NDArray

RETURNS DESCRIPTION
npt.NDArray[np.float32]

preprocessed data


NormalizePreprocessorConfig

Bases: pydantic.BaseModel

Configuration for the from_config class method of NormalizePreprocessor

ATTRIBUTE DESCRIPTION
min_values

minimum values of the data (per channel)

TYPE: list[float]

max_values

maximum values of the data (per channel)

TYPE: list[float]