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[bool] = True)[source]¶
根据 “Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation” 对输入执行大规模抖动 (Large Scale Jitter)。
如果输入是
torch.Tensor
或TVTensor
(例如Image
,Video
,BoundingBoxes
等),它可以有任意数量的批处理维度前导。例如,图像的形状可以是[..., C, H, W]
。边界框的形状可以是[..., 4]
。- 参数:
target_size (tuple of python:int) – 目标尺寸。此参数定义了抖动的基础尺度,例如
min(target_size[0] / width, target_size[1] / height)
。scale_range (tuple of python:float, optional) – 尺度范围的最小值和最大值。默认值:
(0.1, 2.0)
。interpolation (InterpolationMode, optional) – 所需的插值模式,由
torchvision.transforms.InterpolationMode
定义。默认值为InterpolationMode.BILINEAR
。如果输入是 Tensor,仅支持InterpolationMode.NEAREST
,InterpolationMode.NEAREST_EXACT
,InterpolationMode.BILINEAR
和InterpolationMode.BICUBIC
。相应的 Pillow 整数常量(例如PIL.Image.BILINEAR
)也接受。antialias (bool, optional) –
是否应用抗锯齿。它仅影响使用双线性或双三次模式的 tensors,否则将被忽略:对于 PIL 图像,在双线性或双三次模式下总是应用抗锯齿;对于其他模式(PIL 图像和 tensor),抗锯齿没有意义,此参数将被忽略。可能的值为
True
(默认值):对双线性或双三次模式应用抗锯齿。其他模式不受影响。这可能是您希望使用的值。False
:对任何模式下的 tensor 都不应用抗锯齿。PIL 图像在双线性或双三次模式下仍然应用抗锯齿,因为 PIL 不支持不抗锯齿。None
:对于 tensor 相当于False
,对于 PIL 图像相当于True
。此值出于历史原因存在,除非您清楚自己在做什么,否则可能不希望使用它。
默认值在 v0.17 中从
None
更改为True
,以使 PIL 和 Tensor 后端保持一致。