RandomPerspective¶
- class torchaug.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0, batch_inplace=False, num_chunks=1, permute_chunks=False, batch_transform=False)[source]¶
Perform a random perspective transformation of the input with a given probability.
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:
distortion_scale (
float, optional) – argument to control the degree of distortion and ranges from 0 to 1. Default:0.5p (
float, optional) – probability of the input being transformed. Default:0.5interpolation (
Union[InterpolationMode,int], optional) – Desired interpolation enum defined bytorchvision.transforms.InterpolationMode. OnlyInterpolationMode.NEAREST,InterpolationMode.BILINEARare supported. Default:InterpolationMode.BILINEARfill (
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:0batch_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