Skip to content

random_grid_shuffle

RandomGridShuffle

Bases: MultiVariateAlbumentation

Divide an image into a grid and randomly shuffle the grid's cells.

Parameters:

Name Type Description Default
mode Optional[str]

What mode(s) to execute this Op in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train".

None
image_in Optional[str]

The key of an image to be modified.

None
mask_in Optional[str]

The key of a mask to be modified (with the same random factors as the image).

None
masks_in Optional[str]

The key of masks to be modified (with the same random factors as the image).

None
image_out Optional[str]

The key to write the modified image (defaults to image_in if None).

None
mask_out Optional[str]

The key to write the modified mask (defaults to mask_in if None).

None
masks_out Optional[str]

The key to write the modified masks (defaults to masks_in if None).

None
grid Tuple[int, int]

size of grid for splitting image (height, width).

(3, 3)
Image types

uint8, float32

Source code in fastestimator\fastestimator\op\numpyop\multivariate\random_grid_shuffle.py
class RandomGridShuffle(MultiVariateAlbumentation):
    """Divide an image into a grid and randomly shuffle the grid's cells.

    Args:
        mode: What mode(s) to execute this Op in. For example, "train", "eval", "test", or "infer". To execute
            regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument
            like "!infer" or "!train".
        image_in: The key of an image to be modified.
        mask_in: The key of a mask to be modified (with the same random factors as the image).
        masks_in: The key of masks to be modified (with the same random factors as the image).
        image_out: The key to write the modified image (defaults to `image_in` if None).
        mask_out: The key to write the modified mask (defaults to `mask_in` if None).
        masks_out: The key to write the modified masks (defaults to `masks_in` if None).
        grid: size of grid for splitting image (height, width).

    Image types:
        uint8, float32
    """
    def __init__(self,
                 grid: Tuple[int, int] = (3, 3),
                 mode: Optional[str] = None,
                 image_in: Optional[str] = None,
                 mask_in: Optional[str] = None,
                 masks_in: Optional[str] = None,
                 image_out: Optional[str] = None,
                 mask_out: Optional[str] = None,
                 masks_out: Optional[str] = None):
        super().__init__(RandomGridShuffleAlb(grid=grid, always_apply=True),
                         image_in=image_in,
                         mask_in=mask_in,
                         masks_in=masks_in,
                         bbox_in=None,
                         keypoints_in=None,
                         image_out=image_out,
                         mask_out=mask_out,
                         masks_out=masks_out,
                         bbox_out=None,
                         keypoints_out=None,
                         bbox_params=None,
                         keypoint_params=None,
                         mode=mode)