Args: spatial_size: output grid size. grid: grid to be transformed. Shape must be (3, H, W) for 2D or (4, H, W, D) for 3D. randomize: boolean as to whether the grid parameters governing the grid should be randomized. lazy: a flag to indicate w
(
self,
spatial_size: Sequence[int] | None = None,
grid: NdarrayOrTensor | None = None,
randomize: bool = True,
lazy: bool | None = None,
)
| 1917 | self.scale_params = self._get_rand_param(self.scale_range, 1.0) |
| 1918 | |
| 1919 | def __call__( |
| 1920 | self, |
| 1921 | spatial_size: Sequence[int] | None = None, |
| 1922 | grid: NdarrayOrTensor | None = None, |
| 1923 | randomize: bool = True, |
| 1924 | lazy: bool | None = None, |
| 1925 | ) -> torch.Tensor: |
| 1926 | """ |
| 1927 | Args: |
| 1928 | spatial_size: output grid size. |
| 1929 | grid: grid to be transformed. Shape must be (3, H, W) for 2D or (4, H, W, D) for 3D. |
| 1930 | randomize: boolean as to whether the grid parameters governing the grid should be randomized. |
| 1931 | lazy: a flag to indicate whether this transform should execute lazily or not |
| 1932 | during this call. Setting this to False or True overrides the ``lazy`` flag set |
| 1933 | during initialization for this call. Defaults to None. |
| 1934 | |
| 1935 | Returns: |
| 1936 | a 2D (3xHxW) or 3D (4xHxWxD) grid. |
| 1937 | """ |
| 1938 | if randomize: |
| 1939 | self.randomize() |
| 1940 | lazy_ = self.lazy if lazy is None else lazy |
| 1941 | affine_grid = AffineGrid( |
| 1942 | rotate_params=self.rotate_params, |
| 1943 | shear_params=self.shear_params, |
| 1944 | translate_params=self.translate_params, |
| 1945 | scale_params=self.scale_params, |
| 1946 | device=self.device, |
| 1947 | dtype=self.dtype, |
| 1948 | lazy=lazy_, |
| 1949 | ) |
| 1950 | if lazy_: # return the affine only, don't construct the grid |
| 1951 | self.affine = affine_grid(spatial_size, grid)[1] # type: ignore |
| 1952 | return None # type: ignore |
| 1953 | _grid: torch.Tensor |
| 1954 | _grid, self.affine = affine_grid(spatial_size, grid) # type: ignore |
| 1955 | return _grid |
| 1956 | |
| 1957 | def get_transformation_matrix(self) -> torch.Tensor | None: |
| 1958 | """Get the most recently applied transformation matrix""" |
nothing calls this directly
no test coverage detected