ScaleJitter¶
- class torchvision.transforms.v2.ScaleJitter(target_size: Tuple[int, int], scale_range: Tuple[float, float] = (0.1, 2.0), interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR, antialias: Optional[Union[str, bool]] = 'warn')[source]¶
[BETA] Perform Large Scale Jitter on the input according to “Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation”.
Warning
The ScaleJitter transform is in Beta stage, and while we do not expect major breaking changes, some APIs may still change according to user feedback. Please submit any feedback you may have in this issue: https://github.com/pytorch/vision/issues/6753, and you can also check out https://github.com/pytorch/vision/issues/7319 to learn more about the APIs that we suspect might involve future changes.
If the input is a
torch.Tensor
or aDatapoint
(e.g.Image
,Video
,BoundingBox
etc.) 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:
target_size (tuple of python:int) – Target size. This parameter defines base scale for jittering, e.g.
min(target_size[0] / width, target_size[1] / height)
.scale_range (tuple of python:float, optional) – Minimum and maximum of the scale range. Default,
(0.1, 2.0)
.interpolation (InterpolationMode, optional) – Desired interpolation enum defined by
torchvision.transforms.InterpolationMode
. Default isInterpolationMode.BILINEAR
. If input is Tensor, onlyInterpolationMode.NEAREST
,InterpolationMode.NEAREST_EXACT
,InterpolationMode.BILINEAR
andInterpolationMode.BICUBIC
are supported. The corresponding Pillow integer constants, e.g.PIL.Image.BILINEAR
are accepted as well.antialias (bool, optional) –
Whether to apply antialiasing. It only affects tensors with bilinear or bicubic modes and it is ignored otherwise: on PIL images, antialiasing is always applied on bilinear or bicubic modes; on other modes (for PIL images and tensors), antialiasing makes no sense and this parameter is ignored. Possible values are:
True
: will apply antialiasing for bilinear or bicubic modes. Other mode aren’t affected. This is probably what you want to use.False
: will not apply antialiasing for tensors on any mode. PIL images are still antialiased on bilinear or bicubic modes, because PIL doesn’t support no antialias.None
: equivalent toFalse
for tensors andTrue
for PIL images. This value exists for legacy reasons and you probably don’t want to use it unless you really know what you are doing.
The current default is
None
but will change toTrue
in v0.17 for the PIL and Tensor backends to be consistent.