RandomErasing¶
- class torchvision.transforms.RandomErasing(p=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0, inplace=False)[原始碼]¶
隨機選擇 torch.Tensor 影像中的一個矩形區域,並清除其像素。此轉換不支援 PIL 影像。 Zhong 等人的 ‘Random Erasing Data Augmentation’。參見 https://arxiv.org/abs/1708.04896
- 參數:
p – 執行隨機清除操作的機率。
scale – 相對於輸入影像,清除區域比例的範圍。
ratio – 清除區域的長寬比範圍。
value – 清除值。預設值為 0。如果是一個整數,則用於清除所有像素。如果是長度為 3 的元組,則分別用於清除 R、G、B 通道。如果是 ‘random’ 字串,則以隨機值清除每個像素。
inplace – 布林值,用於使此轉換成為原地轉換。預設值設為 False。
- 回傳:
已清除的影像。
範例
>>> transform = transforms.Compose([ >>> transforms.RandomHorizontalFlip(), >>> transforms.PILToTensor(), >>> transforms.ConvertImageDtype(torch.float), >>> transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)), >>> transforms.RandomErasing(), >>> ])