Skip to content
class

GridElasticDeform

extends_DisplacementTransform
GridElasticDeform(num_grid_xy: tuple[int, int] = (4, 4), magnitude: int = 10, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Grid-based elastic deformation (Albumentations GridElasticDeform).

Displaces a coarse num_grid_xy control grid by up to magnitude pixels and upsamples it to a smooth displacement field.

Parameters

num_grid_xy(int, int)= (4, 4)
Control-grid resolution (x, y).
magnitudeint= 10
Max control-point displacement in pixels.
interpolationint or str or Interpolation= 1
No description.
pfloat= 0.5
No description.

Examples

>>> import lucid, lucid.utils.transforms as T
>>> tf = T.GridElasticDeform(p=1.0)
>>> tuple(tf(T.Image(lucid.rand(3, 32, 32))).data.shape)
(3, 32, 32)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(num_grid_xy: tuple[int, int] = (4, 4), magnitude: int = 10, interpolation: int | str | Interpolation = 1, p: float = 0.5)

Instance methods

1
fn

make_params

→DispParams
make_params(img: Tensor)

Sample per-call random parameters for GridElasticDeform.

Parameters

Image tensor; its spatial size sets the displacement field size and the output canvas.

Returns

DispParams

Carries per-pixel dx / dy fields of shape (H, W) in pixel units, built by sampling a (num_grid_xy[1] + 1, num_grid_xy[0] + 1) control grid with entries uniform in [-magnitude, magnitude] and bilinearly upsampling to (H, W). out_hw equals the input (H, W).

Dunder methods

1