Skip to content

mask_dropout

MaskDropout

Bases: MultiVariateAlbumentation

Zero out objects from an image + mask pair.

An image & mask augmentation that zero out mask and image regions corresponding to randomly chosen object instance from mask. The mask must be single-channel image, with zero values treated as background. The image can be any number of channels.

Parameters:

Name Type Description Default
mode Union[None, str, Iterable[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
ds_id Union[None, str, Iterable[str]]

What dataset id(s) to execute this Op in. To execute regardless of ds_id, pass None. To execute in all ds_ids except for a particular one, you can pass an argument like "!ds1".

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). image_out: 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
max_objects Union[int, Tuple[int, int]]

Maximum number of labels that can be zeroed out. Can be tuple, in this case it's [min, max]

1
image_fill_value Union[int, float, str]

Fill value to use when filling image. Can be 'inpaint' to apply in-painting (works only for 3-channel images)

0
mask_fill_value Union[int, float]

Fill value to use when filling mask.

0
Image types

uint8, float32

Source code in fastestimator/fastestimator/op/numpyop/multivariate/mask_dropout.py
@traceable()
class MaskDropout(MultiVariateAlbumentation):
    """Zero out objects from an image + mask pair.

    An image & mask augmentation that zero out mask and image regions corresponding to randomly chosen object instance
    from mask. The mask must be single-channel image, with zero values treated as background. The image can be any
    number of channels.

    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".
        ds_id: What dataset id(s) to execute this Op in. To execute regardless of ds_id, pass None. To execute in all
            ds_ids except for a particular one, you can pass an argument like "!ds1".
        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).
        max_objects: Maximum number of labels that can be zeroed out. Can be tuple, in this case it's [min, max]
        image_fill_value: Fill value to use when filling image.
            Can be 'inpaint' to apply in-painting (works only  for 3-channel images)
        mask_fill_value: Fill value to use when filling mask.

    Image types:
        uint8, float32
    """
    def __init__(self,
                 max_objects: Union[int, Tuple[int, int]] = 1,
                 image_fill_value: Union[int, float, str] = 0,
                 mask_fill_value: Union[int, float] = 0,
                 mode: Union[None, str, Iterable[str]] = None,
                 ds_id: Union[None, str, Iterable[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__(
            MaskDropoutAlb(max_objects=max_objects,
                           image_fill_value=image_fill_value,
                           mask_fill_value=mask_fill_value,
                           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,
            ds_id=ds_id)