class FusedColorJitter(torch.nn.Module):
随机更改图像的亮度、对比度、饱和度和色调。
- 参数:
- brightness (Float或Tuple of float (min, max)) - 亮度调整值。Brightness_factor统一从[max(0, 1 - brightness), 1 + brightness]或给定的[min, max]中选择。非负数。
- contrast (Float或Tuple of float (min, max)) - 对比度调整值。Contrast_factor统一从[max(0, 1 - contrast), 1 + contrast]或给定的[min, max]中选择。非负数。
- saturation (Float或Tuple of float (min, max)) - 饱和度调整值。Saturation_factor统一从[max(0, 1 - saturation), 1 + saturation]或给定的[min, max]中选择。非负数。
- hue (Float或Tuple of float (min, max)) - 色调调整值。Hue_factor统一从[-hue, hue]或给定的[min, max]中选择,且满足0<= hue <= 0.5或-0.5 <= min <= max <= 0.5
- 调用方式样例:
from torch_npu.contrib.module import FusedColorJitter
fcj = FusedColorJitter(0.1, 0.1, 0.1, 0.1)
- 示例:
from PIL import Image
image = Image.fromarray(torch.randint(0, 256, size=(224, 224, 3)).numpy().astype(np.uint8))
fcj = FusedColorJitter(0.1, 0.1, 0.1, 0.1)
image = fcj(image)