Skip to content

normalize

Normalize

Bases: ImageOnlyAlbumentation

Divide pixel values by a maximum value, subtract mean per channel and divide by std per channel.

Parameters:

Name Type Description Default
inputs Union[str, Iterable[str], Callable]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
mode Union[None, str, Iterable[str]]

What mode(s) to execute this Op in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train".

None
mean Union[float, Tuple[float, ...]]

Mean values to subtract.

(0.485, 0.456, 0.406)
std Union[float, Tuple[float, ...]]

The divisor.

(0.229, 0.224, 0.225)
max_pixel_value float

Maximum possible pixel value.

255.0
Image types

uint8, float32

Source code in fastestimator\fastestimator\op\numpyop\univariate\normalize.py
class Normalize(ImageOnlyAlbumentation):
    """Divide pixel values by a maximum value, subtract mean per channel and divide by std per channel.

    Args:
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        mode: What mode(s) to execute this Op in. For example, "train", "eval", "test", or "infer". To execute
            regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument
            like "!infer" or "!train".
        mean: Mean values to subtract.
        std: The divisor.
        max_pixel_value: Maximum possible pixel value.

    Image types:
        uint8, float32
    """
    def __init__(self,
                 inputs: Union[str, Iterable[str], Callable],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None,
                 mean: Union[float, Tuple[float, ...]] = (0.485, 0.456, 0.406),
                 std: Union[float, Tuple[float, ...]] = (0.229, 0.224, 0.225),
                 max_pixel_value: float = 255.0):
        super().__init__(NormalizeAlb(mean=mean, std=std, max_pixel_value=max_pixel_value, always_apply=True),
                         inputs=inputs,
                         outputs=outputs,
                         mode=mode)