AutoAugment¶
- class torchvision.transforms.AutoAugment(policy: AutoAugmentPolicy = AutoAugmentPolicy.IMAGENET, interpolation: InterpolationMode = InterpolationMode.NEAREST, fill: Optional[list[float]] = None)[原始碼]¶
基於 “AutoAugment: Learning Augmentation Strategies from Data” 的 AutoAugment 資料增強方法。如果影像是 torch Tensor,則其型別應為 torch.uint8,並期望其形狀為 […, 1 或 3, H, W],其中 … 表示任意數量的前導維度。如果 img 是 PIL Image,則期望其模式為 “L” 或 “RGB”。
- 引數:
policy (AutoAugmentPolicy) – 由
torchvision.transforms.autoaugment.AutoAugmentPolicy定義的期望策略列舉。預設為AutoAugmentPolicy.IMAGENET。interpolation (InterpolationMode) – 由
torchvision.transforms.InterpolationMode定義的期望插值列舉。預設為InterpolationMode.NEAREST。如果輸入是 Tensor,則僅支援InterpolationMode.NEAREST和InterpolationMode.BILINEAR。fill (sequence 或 number, 可選) – 轉換後圖像外部區域的畫素填充值。如果給定一個數字,則該值分別用於所有通道。
使用
AutoAugment的示例- forward(img: Tensor) Tensor[原始碼]¶
img (PIL Image 或 Tensor): 要轉換的影像。
- 返回:
AutoAugmented 影像。
- 返回型別:
PIL 影像或張量
- static get_params(transform_num: int) tuple[int, torch.Tensor, torch.Tensor][原始碼]¶
獲取 autoaugment 變換的引數
- 返回:
autoaugment 變換所需的引數