mmagic.datasets.transforms.random_degradations
¶
Module Contents¶
Classes¶
Apply random blur to the input. |
|
Apply random JPEG compression to the input. |
|
Apply random noise to the input. |
|
Randomly resize the input. |
|
Apply random video compression to the input. |
|
Apply random degradations to input, with degradations being shuffled. |
Attributes¶
- class mmagic.datasets.transforms.random_degradations.RandomBlur(params, keys)[source]¶
Apply random blur to the input.
Modified keys are the attributed specified in “keys”.
- Parameters
params (dict) – A dictionary specifying the degradation settings.
keys (list[str]) – A list specifying the keys whose values are modified.
- get_kernel(num_kernels: int)[source]¶
This is the function to create kernel.
- Parameters
num_kernels (int) – the number of kernels
- Returns
_description_
- Return type
_type_
- class mmagic.datasets.transforms.random_degradations.RandomJPEGCompression(params, keys, color_type='color', bgr2rgb=False)[source]¶
Apply random JPEG compression to the input.
Modified keys are the attributed specified in “keys”.
- Parameters
params (dict) – A dictionary specifying the degradation settings.
keys (list[str]) – A list specifying the keys whose values are modified.
bgr2rgb (str) – Whether change channel order. Default: False.
- class mmagic.datasets.transforms.random_degradations.RandomNoise(params, keys)[source]¶
Apply random noise to the input.
Currently support Gaussian noise and Poisson noise.
Modified keys are the attributed specified in “keys”.
- Parameters
params (dict) – A dictionary specifying the degradation settings.
keys (list[str]) – A list specifying the keys whose values are modified.
- _apply_gaussian_noise(imgs)[source]¶
This is the function used to apply gaussian noise on images.
- Parameters
imgs (Tensor) – images
- Returns
images applied gaussian noise
- Return type
Tensor
- class mmagic.datasets.transforms.random_degradations.RandomResize(params, keys)[source]¶
Randomly resize the input.
Modified keys are the attributed specified in “keys”.
- Parameters
params (dict) – A dictionary specifying the degradation settings.
keys (list[str]) – A list specifying the keys whose values are modified.
- class mmagic.datasets.transforms.random_degradations.RandomVideoCompression(params, keys)[source]¶
Apply random video compression to the input.
Modified keys are the attributed specified in “keys”.
- Parameters
params (dict) – A dictionary specifying the degradation settings.
keys (list[str]) – A list specifying the keys whose values are modified.
- class mmagic.datasets.transforms.random_degradations.DegradationsWithShuffle(degradations, keys, shuffle_idx=None)[source]¶
Apply random degradations to input, with degradations being shuffled.
Degradation groups are supported. The order of degradations within the same group is preserved. For example, if we have degradations = [a, b, [c, d]] and shuffle_idx = None, then the possible orders are
[a, b, [c, d]] [a, [c, d], b] [b, a, [c, d]] [b, [c, d], a] [[c, d], a, b] [[c, d], b, a]
Modified keys are the attributed specified in “keys”.
- Parameters
degradations (list[dict]) – The list of degradations.
keys (list[str]) – A list specifying the keys whose values are modified.
shuffle_idx (list | None, optional) – The degradations corresponding to these indices are shuffled. If None, all degradations are shuffled. Default: None.