class
XYMasking
extends
PhotometricTransform[BandParams]XYMasking(num_masks_x: int = 0, num_masks_y: int = 0, mask_x_length: int = 10, mask_y_length: int = 10, fill_value: float = 0.0, p: float = 0.5)Mask random horizontal and vertical bands of the image (Albumentations XYMasking).
Samples num_masks_x vertical column-bands of width
mask_x_length and num_masks_y horizontal row-bands of height
mask_y_length, each placed at a uniformly-sampled offset. All
sampled bands are unioned into a single multiplicative keep-mask
and applied via the standard mask + fill pattern. Equivalent to
SpecAugment-style time / frequency masking but for spatial inputs.
Parameters
num_masks_xint= 0Number of vertical (column-direction) bands to sample.
num_masks_yint= 0Number of horizontal (row-direction) bands to sample.
mask_x_lengthint= 10Width in pixels of each vertical band.
mask_y_lengthint= 10Height in pixels of each horizontal band.
fill_valuefloat= 0.0Value written into the masked bands.
pfloat= 0.5Probability of applying the transform.
Examples
>>> import lucid
>>> import lucid.utils.transforms as T
>>> tf = T.XYMasking(num_masks_x=2, num_masks_y=2, mask_x_length=8, mask_y_length=8, 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
1Sample per-call random parameters for XYMasking.
Parameters
imgTensorImage tensor; its spatial size is read to bound the
uniformly-sampled band start positions.
Returns
BandParamsCarries rows (num_masks_y horizontal band intervals)
and cols (num_masks_x vertical band intervals),
each interval (start, stop) with width mask_y_length
/ mask_x_length (clipped to the image edge).