Skip to content

rua

AutoContrast

Bases: AutoContrastAug

Adjust image contrast automatically.

Parameters:

Name Type Description Default
level Union[int, float]

Placeholder argument to conform to RUA.

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class AutoContrast(AutoContrastAug):
    """Adjust image contrast automatically.

    Args:
        level: Placeholder argument to conform to RUA.
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)

Brightness

Bases: BrightnessAug

Randomly change the brightness of an image.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for brightness. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Brightness(BrightnessAug):
    """Randomly change the brightness of an image.

    Args:
        level: Factor to set the range for brightness. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, limit=level / 30 * 0.9)

Color

Bases: ColorAug

Randomly change the color balance of an image.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for changing color balance. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Color(ColorAug):
    """Randomly change the color balance of an image.

    Args:
        level: Factor to set the range for changing color balance. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, limit=level / 30 * 0.9)

Contrast

Bases: ContrastAug

Randomly change the contrast of an image.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for contrast. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Contrast(ContrastAug):
    """Randomly change the contrast of an image.

    Args:
        level: Factor to set the range for contrast. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, limit=level / 30 * 0.9)

Equalize

Bases: NumpyOp

Equalize the image histogram.

This is a wrapper for functionality provided by the PIL library: https://github.com/python-pillow/Pillow/tree/master/src/PIL.

Parameters:

Name Type Description Default
level Union[int, float]

Placeholder argument to conform to RUA.

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Equalize(NumpyOp):
    """Equalize the image histogram.

    This is a wrapper for functionality provided by the PIL library:
    https://github.com/python-pillow/Pillow/tree/master/src/PIL.

    Args:
        level: Placeholder argument to conform to RUA.
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)
        self.in_list, self.out_list = True, True

    def forward(self, data: List[np.ndarray], state: Dict[str, Any]) -> List[np.ndarray]:
        return [self._apply_equalize(elem) for elem in data]

    def _apply_equalize(self, data: np.ndarray) -> np.ndarray:
        im = Image.fromarray(data)
        im = ImageOps.equalize(im)
        return np.array(im)

Identity

Bases: NumpyOp

Pass the input as-is.

Parameters:

Name Type Description Default
level Union[int, float]

Placeholder argument to conform to RUA.

required
inputs Union[str, Iterable[str]]

Key(s) of images.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the images.

required
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
Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Identity(NumpyOp):
    """Pass the input as-is.

    Args:
        level: Placeholder argument to conform to RUA.
        inputs: Key(s) of images.
        outputs: Key(s) into which to write the images.
        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".
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)
        self.in_list, self.out_list = True, True

Posterize

Bases: PosterizeAug

Reduce the number of bits for the image.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for number of bits. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Posterize(PosterizeAug):
    """Reduce the number of bits for the image.

    Args:
        level: Factor to set the range for number of bits. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, num_bits=(round(8 - (level / 30 * 7)), 8))

RUA

Bases: NumpyOp

Apply RUA augmentation strategy.

Parameters:

Name Type Description Default
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
level Union[int, float]

Factor to set the range for magnitude of augmentation. Must be in the range [0, 30].

18
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class RUA(NumpyOp):
    """Apply RUA augmentation strategy.

    Args:
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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".
        level: Factor to set the range for magnitude of augmentation. Must be in the range [0, 30].

    Image types:
        uint8
    """
    def __init__(self,
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None,
                 level: Union[int, float] = 18):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)
        aug_options = self._get_aug_list(level=level)
        self.ops = [OneOf(*aug_options) for _ in range(self._num_aug(level, len(aug_options)))]
        self.in_list, self.out_list = True, True

    def _num_aug(self, level: Union[int, float], len_aug_list: int) -> int:
        max_N = min(5, len_aug_list)
        N = min(max_N, math.ceil(level / 30 * max_N))
        return N

    def _get_aug_list(self, level: Union[int, float]) -> List[NumpyOp]:
        aug_options = [
            Rotate(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Identity(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            AutoContrast(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Equalize(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Posterize(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Solarize(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Sharpness(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Contrast(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Color(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            Brightness(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            ShearX(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            ShearY(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            TranslateX(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode),
            TranslateY(level=level, inputs=self.inputs, outputs=self.outputs, mode=self.mode)
        ]
        return aug_options

    def forward(self, data: List[np.ndarray], state: Dict[str, Any]) -> List[np.ndarray]:
        data = {key: elem for key, elem in zip(self.inputs, data)}
        forward_numpyop(self.ops, data, state)
        return [data[key] for key in self.outputs]

Rotate

Bases: NumpyOp

Rotate the input by an angle selected randomly.

This is a wrapper for functionality provided by the PIL library: https://github.com/python-pillow/Pillow/tree/master/src/PIL.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for rotation. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Rotate(NumpyOp):
    """Rotate the input by an angle selected randomly.

    This is a wrapper for functionality provided by the PIL library:
    https://github.com/python-pillow/Pillow/tree/master/src/PIL.

    Args:
        level: Factor to set the range for rotation. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)
        self.degree = level * 3.0
        self.in_list, self.out_list = True, True

    def forward(self, data: List[np.ndarray], state: Dict[str, Any]) -> List[np.ndarray]:
        return [self._apply_rotate(elem) for elem in data]

    def _apply_rotate(self, data: np.ndarray) -> np.ndarray:
        im = Image.fromarray(data)
        degree = random.uniform(-self.degree, self.degree)
        im = im.rotate(degree)
        return np.array(im)

Sharpness

Bases: SharpnessAug

Randomly change the sharpness of an image.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for sharpness. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Sharpness(SharpnessAug):
    """Randomly change the sharpness of an image.

    Args:
        level: Factor to set the range for sharpness. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, limit=level / 30 * 0.9)

ShearX

Bases: ShearXAug

Randomly shear the image along the X axis.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for shear. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class ShearX(ShearXAug):
    """Randomly shear the image along the X axis.

    Args:
        level: Factor to set the range for shear. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, shear_coef=level / 30 * 0.5)

ShearY

Bases: ShearYAug

Randomly shear the image along the Y axis.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for shear. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class ShearY(ShearYAug):
    """Randomly shear the image along the Y axis.

    Args:
        level: Factor to set the range for shear. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, shear_coef=level / 30 * 0.5)

Solarize

Bases: NumpyOp

Invert all pixel values above a threshold.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for the threshold. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class Solarize(NumpyOp):
    """Invert all pixel values above a threshold.

    Args:
        level: Factor to set the range for the threshold. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode)
        self.loss_limit = level / 30 * 256
        self.in_list, self.out_list = True, True

    def forward(self, data: List[np.ndarray], state: Dict[str, Any]) -> List[np.ndarray]:
        return [self._apply_solarize(elem) for elem in data]

    def _apply_solarize(self, data: np.ndarray) -> np.ndarray:
        threshold = 256 - round(random.uniform(0, self.loss_limit))
        data = np.where(data < threshold, data, 255 - data)
        return data

TranslateX

Bases: TranslateXAug

Randomly shift the image along the X axis.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for shift. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class TranslateX(TranslateXAug):
    """Randomly shift the image along the X axis.

    Args:
        level: Factor to set the range for shift. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, shift_limit=level / 30 * 1 / 3)

TranslateY

Bases: TranslateYAug

Randomly shift the image along the Y axis.

Parameters:

Name Type Description Default
level Union[int, float]

Factor to set the range for shift. Must be in the range [0, 30].

required
inputs Union[str, Iterable[str]]

Key(s) of images to be modified.

required
outputs Union[str, Iterable[str]]

Key(s) into which to write the modified images.

required
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
Image types

uint8

Source code in fastestimator\fastestimator\op\numpyop\univariate\rua.py
@traceable()
class TranslateY(TranslateYAug):
    """Randomly shift the image along the Y axis.

    Args:
        level: Factor to set the range for shift. Must be in the range [0, 30].
        inputs: Key(s) of images to be modified.
        outputs: Key(s) into which to write the modified images.
        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 types:
        uint8
    """
    def __init__(self,
                 level: Union[int, float],
                 inputs: Union[str, Iterable[str]],
                 outputs: Union[str, Iterable[str]],
                 mode: Union[None, str, Iterable[str]] = None):
        super().__init__(inputs=inputs, outputs=outputs, mode=mode, shift_limit=level / 30 * 1 / 3)