Skip to content
class

Normalize

extends_NoParamsPhotometricTransform[Empty]
Normalize(mean: tuple[float, ...], std: tuple[float, ...], max_pixel_value: float = 255.0, p: float = 1.0)

Normalize an image (Albumentations Normalize).

Computes (img - mean * max_pixel_value) / (std * max_pixel_value) — i.e. scales by max_pixel_value then standardizes per channel.

Parameters

meantuple of float
Per-channel statistics.
stdtuple of float
Per-channel statistics.
max_pixel_valuefloat= 255.0
Value the inputs are divided by (1.0 for [0, 1] inputs).
pfloat= 1.0
No description.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.Normalize(mean=(0.485, 0.456, 0.406),
...                  std=(0.229, 0.224, 0.225), max_pixel_value=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 32, 32)
max_pixel_value divides before the mean is taken, so it is 255
for an image read from a file and 1.0 for one already in 0-1.

Used by 2

Constructors

1
dunder

__init__

→None
__init__(mean: tuple[float, ...], std: tuple[float, ...], max_pixel_value: float = 255.0, p: float = 1.0)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1