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)[源码]¶
根据 “Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation” 对输入执行大规模抖动。
如果输入是
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) –
是否应用抗锯齿。它仅影响双线性或双三次模式下的张量,否则将被忽略:在 PIL 图像上,双线性或双三次模式始终应用抗锯齿;在其他模式下(对于 PIL 图像和张量),抗锯齿没有意义,此参数将被忽略。可能的值为
True
(默认):将对双线性或双三次模式应用抗锯齿。其他模式不受影响。这可能是您想要使用的。False
:将不对任何模式下的张量应用抗锯齿。PIL 图像在双线性或双三次模式下仍然进行抗锯齿处理,因为 PIL 不支持无抗锯齿。None
:对于张量相当于False
,对于 PIL 图像相当于True
。此值存在是为了兼容性,除非您真的知道自己在做什么,否则可能不希望使用它。
默认值在 v0.17 中从
None
更改为True
,以使 PIL 和 Tensor 后端保持一致。