RandomAffine¶
- class torchaug.transforms.RandomAffine(degrees, translate=None, scale=None, shear=None, interpolation=InterpolationMode.NEAREST, fill=0, center=None, batch_inplace=False, num_chunks=1, permute_chunks=False, batch_transform=False)[source]¶
Random affine transformation the input keeping center invariant.
If the input is a
torch.Tensoror aTATensor(e.g.Image,Video,BoundingBoxesetc.) it can have arbitrary number of leading batch dimensions. For example, the image can have[..., C, H, W]shape. A bounding box can have[..., 4]shape.- Parameters:
degrees (
Union[Number,Sequence]) – Range of degrees to select from. If degrees is a number instead of sequence like (min, max), the range of degrees will be (-degrees, +degrees). Set to 0 to deactivate rotations.translate (
Optional[Sequence[float]], optional) – tuple of maximum absolute fraction for horizontal and vertical translations. For example translate=(a, b), then horizontal shift is randomly sampled in the range -img_width * a < dx < img_width * a and vertical shift is randomly sampled in the range -img_height * b < dy < img_height * b. Will not translate by default. Default:Nonescale (
Optional[Sequence[float]], optional) – scaling factor interval, e.g (a, b), then scale is randomly sampled from the range a <= scale <= b. Will keep original scale by default. Default:Noneshear (
Union[int,float,Sequence[float],None], optional) – Range of degrees to select from. If shear is a number, a shear parallel to the x-axis in the range (-shear, +shear) will be applied. Else if shear is a sequence of 2 values a shear parallel to the x-axis in the range (shear[0], shear[1]) will be applied. Else if shear is a sequence of 4 values, an x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied. Will not apply shear by default. Default:Noneinterpolation (
Union[InterpolationMode,int], optional) – Desired interpolation enum defined bytorchvision.transforms.InterpolationMode. OnlyInterpolationMode.NEAREST,InterpolationMode.BILINEARare supported. Default:InterpolationMode.NEARESTfill (
Union[int,float,Sequence[int],Sequence[float],None,Dict[Union[Type,str],Union[int,float,Sequence[int],Sequence[float],None]]], optional) – Pixel fill value used when thepadding_modeis constant. If a tuple of length 3, it is used to fill R, G, B channels respectively. Fill value can be also a dictionary mapping data type to the fill value, e.g.fill={ta_tensors.Image: 127, ta_tensors.Mask: 0}whereImagewill be filled with 127 andMaskwill be filled with 0. Default:0center (
Optional[List[float]], optional) – Optional center of rotation, (x, y). Origin is the upper left corner. Default is the center of the image. Default:Nonebatch_inplace (
bool, optional) – whether to apply the batch transform in-place. Does not prevent functionals to make copy but can reduce time and memory consumption. Default:Falsenum_chunks (
int, optional) – number of chunks to split the batched input into. Default:1permute_chunks (
bool, optional) – whether to permute the chunks. Default:Falsebatch_transform (
bool, optional) – whether to apply the transform in batch mode. Default:False