class
FancyPCA
extends
PhotometricTransform[Empty]FancyPCA(alpha: float = 0.1, p: float = 0.5)AlexNet-style PCA colour augmentation (Krizhevsky 2012, Albumentations FancyPCA).
Computes the per-image RGB covariance matrix, takes its
eigendecomposition, and adds a random linear combination of the
eigenvectors weighted by their eigenvalues to every pixel. The
weights are i.i.d. samples from alpha * U(-1, 1) per channel —
same recipe used in the original AlexNet training pipeline.
Parameters
alphafloat= 0.1Standard deviation scale on the eigenvalue-weighted perturbation;
larger values give more colour jitter.
pfloat= 0.5Probability of applying the transform.
Raises
ValueErrorIf the input image does not have exactly 3 channels.
Examples
>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.FancyPCA(alpha=0.1, p=1.0)
>>> out = tf(T.Image(lucid.rand(3, 32, 32))).data
>>> tuple(out.shape)
(3, 32, 32)Used by 1
Constructors
1Instance methods
1Return the no-op parameter sentinel for FancyPCA.
Parameters
imgTensorImage tensor; not inspected here.
Returns
EmptyThe shared NO_PARAMS sentinel — the random
eigenvector weights are drawn inline in the apply step
because they depend on the per-image covariance
decomposition.