快捷方式

RandAugment

class torchvision.transforms.RandAugment(num_ops: int = 2, magnitude: int = 9, num_magnitude_bins: int = 31, interpolation: InterpolationMode = InterpolationMode.NEAREST, fill: Optional[List[float]] = None)[原始碼]

RandAugment 資料增強方法,基於 “RandAugment: Practical automated data augmentation with a reduced search space”。如果影像是 torch Tensor,則應為 torch.uint8 型別,並且期望形狀為 […, 1 or 3, H, W],其中 … 表示任意數量的前導維度。如果 img 是 PIL Image,則期望模式為 “L” 或 “RGB”。

引數:
  • num_ops (int) – 順序應用的增強變換次數。

  • magnitude (int) – 所有變換的強度。

  • num_magnitude_bins (int) – 不同的強度值數量。

  • interpolation (InterpolationMode) – 由 torchvision.transforms.InterpolationMode 定義的所需插值列舉。預設值為 InterpolationMode.NEAREST。如果輸入是 Tensor,僅支援 InterpolationMode.NEARESTInterpolationMode.BILINEAR

  • fill (序列數字, 可選) – 變換後圖像外部區域的畫素填充值。如果給定一個數字,則該值將分別用於所有波段。

使用 RandAugment 的示例

變換圖示

變換圖示
forward(img: Tensor) Tensor[原始碼]

img (PIL Image 或 Tensor): 要變換的影像。

返回:

變換後的影像。

返回型別:

PIL Image 或 Tensor

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源