RandomPhotometricDistort¶
- class torchvision.transforms.v2.RandomPhotometricDistort(brightness: tuple[float, float] = (0.875, 1.125), contrast: tuple[float, float] = (0.5, 1.5), saturation: tuple[float, float] = (0.5, 1.5), hue: tuple[float, float] = (- 0.05, 0.05), p: float = 0.5)[source]¶
随机扭曲图像或视频,如SSD: Single Shot MultiBox Detector中所使用的。
此转换在后台依赖于
ColorJitter
来调整对比度、饱和度、色调、亮度,并随机排列通道。- 参数:
brightness (tuple of python:float (min, max), optional) – 调整亮度的幅度。brightness_factor 从 [min, max] 中均匀选择。应为非负数。
contrast (tuple of python:float (min, max), optional) – 调整对比度的幅度。contrast_factor 从 [min, max] 中均匀选择。应为非负数。
saturation (tuple of python:float (min, max), optional) – 调整饱和度的幅度。saturation_factor 从 [min, max] 中均匀选择。应为非负数。
hue (tuple of python:float (min, max), optional) – 调整色调的幅度。hue_factor 从 [min, max] 中均匀选择。应满足 -0.5 <= min <= max <= 0.5。要调整色调,输入图像的像素值必须为非负数才能转换为 HSV 空间;因此,如果您将图像归一化为包含负值的区间,或在调用此函数之前使用会生成负值的插值,则此功能将不起作用。
p (float, optional) 每个失真操作的概率 (对比度, 饱和度, ...) – 默认值为 0.5。
使用
RandomPhotometricDistort
的示例