GridMask
Targets:
image
mask
bboxes
keypoints
Image Types:uint8, float32
Drop grid-line regions (horizontal and vertical stripes). num_grid_range, line_width_range, rotation_range, fill. Unlike GridDropout which drops cells.
Arguments
num_grid_rangetuple[int, int]
[3,7]
Range for number of grid divisions along the shorter image side. Default: (3, 7).
line_width_rangetuple[float, float]
[0.2,0.5]
Range for line width as a fraction of grid cell size. Default: (0.2, 0.5).
rotation_rangetuple[float, float]
[0,0]
Range for grid rotation in radians. Default: (0, 0) (no rotation).
filltuple[float, ...] | float | random | random_uniform | inpaint_telea | inpaint_ns
0
Fill value for dropped pixels. Default: 0.
fill_masktuple[float, ...] | float | None
Fill value for mask. Default: None.
pfloat
0.5
Probability of applying the transform. Default: 0.5.
Examples
>>> 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"]Notes
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).
References
- GridMask paperhttps://arxiv.org/abs/2001.04086