GridMask
Apply GridMask augmentation by dropping grid-line regions.
Unlike GridDropout which drops rectangular cells, GridMask drops the grid lines themselves — continuous horizontal and vertical stripes forming a grid pattern. The grid can optionally be rotated.
num_grid_rangeRange for number of grid divisions along the shorter image side. Default: (3, 7).
line_width_rangeRange for line width as a fraction of grid cell size. Default: (0.2, 0.5).
rotation_rangeRange for grid rotation in radians. Default: (0, 0) (no rotation).
fillFill value for dropped pixels. Default: 0.
fill_maskFill value for mask. Default: None.
pProbability of applying the transform. Default: 0.5.
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> transform = A.GridMask(num_grid_range=(3, 5), line_width_range=(0.2, 0.4), p=1.0)
>>> result = transform(image=image)["image"]GridMask was shown to outperform AutoAugment while being less computationally expensive. It achieves +1.4% on ImageNet (ResNet50), +1.8% on COCO detection (FasterRCNN-50-FPN), and +0.8% on Cityscapes segmentation (PSPNet50).
- GridMask paperhttps://arxiv.org/abs/2001.04086