快捷鍵

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”,對輸入執行大規模的 Scale Jitter。

如果輸入是 torch.Tensor 或是 TVTensor (例如 ImageVideoBoundingBoxes 等),則它可以具有任意數量的 leading batch 維度。 例如,圖像可以具有 [..., C, H, W] 形狀。 邊界框可以具有 [..., 4] 形狀。

參數:
  • target_size (tuple of python:int) – 目標尺寸。 此參數定義抖動 (jittering) 的基本比例,例如 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.NEARESTInterpolationMode.NEAREST_EXACTInterpolationMode.BILINEARInterpolationMode.BICUBIC。 也接受對應的 Pillow 整數常數,例如 PIL.Image.BILINEAR

  • antialias (bool, optional) –

    是否應用抗鋸齒 (antialiasing)。 它僅影響具有雙線性或雙三次模式的 tensors,否則會被忽略:在 PIL 圖像上,始終在雙線性或雙三次模式下應用抗鋸齒;在其他模式(對於 PIL 圖像和 tensors)下,抗鋸齒沒有意義,並且此參數將被忽略。 可能的值包括

    • True (預設值):將對雙線性或雙三次模式應用抗鋸齒。 其他模式不受影響。 這可能是您想要使用的。

    • False:不會對任何模式下的 tensors 應用抗鋸齒。 PIL 圖像仍然會在雙線性或雙三次模式下進行抗鋸齒處理,因為 PIL 不支援不進行抗鋸齒。

    • None:對於 tensors 等同於 False,對於 PIL 圖像等同於 True。 此值出於舊版原因而存在,除非您確實知道自己在做什麼,否則您可能不想使用它。

    為了使 PIL 和 Tensor 後端保持一致,預設值已在 v0.17 中從 None 變更為 True

make_params(flat_inputs: List[Any]) Dict[str, Any][source]

覆寫自定義轉換的方法。

請參閱 如何編寫自己的 v2 轉換

transform(inpt: Any, params: Dict[str, Any]) Any[source]

覆寫自定義轉換的方法。

請參閱 如何編寫自己的 v2 轉換

文件

存取 PyTorch 的完整開發人員文件

檢視文件

教學

取得針對初學者和進階開發人員的深入教學課程

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源