nvidia.dali.fn.noise.salt_and_pepper#

nvidia.dali.fn.noise.salt_and_pepper(__input, /, *, bytes_per_sample_hint=[0], pepper_val=None, per_channel=False, preserve=False, prob=0.05, salt_val=None, salt_vs_pepper=0.5, seed=-1, device=None, name=None)#

Applies salt-and-pepper noise to the input.

The shape and data type of the output will match the input.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

__input (TensorList) – Input to the operator.

Keyword Arguments:
  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • pepper_val (float or TensorList of float, optional) –

    Value of “pepper”.

    If not provided, the pepper value will be -1.0 for floating point types or the minimum value of the input data type otherwise, converted to the data type of the input.

  • per_channel (bool, optional, default = False) –

    Determines whether the noise should be generated for each channel independently.

    If set to True, the noise is generated for each channel independently, resulting in some channels being corrupted and others kept intact. If set to False, the noise is generated once and applied to all channels, so that all channels in a pixel should either be kept intact, take the “pepper” value, or the “salt” value.

    Note: Per-channel noise generation requires the input layout to contain a channels (‘C’) dimension, or be empty. In the case of the layout being empty, channel-last layout is assumed.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • prob (float or TensorList of float, optional, default = 0.05) – Probability of an output value to take a salt or pepper value.

  • salt_val (float or TensorList of float, optional) –

    Value of “salt”.

    If not provided, the salt value will be 1.0 for floating point types or the maximum value of the input data type otherwise, converted to the data type of the input.

  • salt_vs_pepper (float or TensorList of float, optional, default = 0.5) – Probability of a corrupted output value to take a salt value.

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.