随机擦除¶
- class torchvision.transforms.v2.RandomErasing(p: float = 0.5, scale: Sequence[float] = (0.02, 0.33), ratio: Sequence[float] = (0.3, 3.3), value: float = 0.0, inplace: bool = False)[source]¶
随机选择输入图像或视频中的矩形区域并擦除其像素。
此转换不支持 PIL Image。Zhong 等人的“随机擦除数据增强”。查看 https://arxiv.org/abs/1708.04896
- 参数:
- 返回值:
擦除的输入。
示例
>>> from torchvision.transforms import v2 as transforms >>> >>> 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(), >>> ])