RandomAffine — Torchvision 0.22 documentation (original) (raw)

class torchvision.transforms.RandomAffine(degrees, translate=None, scale=None, shear=None, interpolation=InterpolationMode.NEAREST, fill=0, center=None)[source]

Random affine transformation of the image keeping center invariant. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions.

Parameters:

Examples using RandomAffine:

forward(img)[source]

img (PIL Image or Tensor): Image to be transformed.

Returns:

Affine transformed image.

Return type:

PIL Image or Tensor

static get_params(degrees: List[float], translate: Optional[List[float]], scale_ranges: Optional[List[float]], shears: Optional[List[float]], img_size: List[int]) → Tuple[float, Tuple[int, int], float, Tuple[float, float]][source]

Get parameters for affine transformation

Returns:

params to be passed to the affine transformation