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)[源代码]¶
随机扭曲图像或视频,如 SSD: Single Shot MultiBox Detector 中所用。
此转换在底层依赖
ColorJitter
来调整对比度、饱和度、色调、亮度,并随机排列通道。- 参数:
brightness (python:float 元组 (min, max),可选) – 亮度抖动幅度。brightness_factor 从 [min, max] 均匀选择。应为非负数。
contrast (python:float 元组 (min, max),可选) – 对比度抖动幅度。contrast_factor 从 [min, max] 均匀选择。应为非负数。
saturation (python:float 元组 (min, max),可选) – 饱和度抖动幅度。saturation_factor 从 [min, max] 均匀选择。应为非负数。
hue (python:float 元组 (min, max),可选) – 色调抖动幅度。hue_factor 从 [min, max] 均匀选择。应满足 -0.5 <= min <= max <= 0.5。要抖动色调,输入图像的像素值必须为非负数,以便转换为 HSV 空间;因此,如果将图像归一化为具有负值的区间,或者在使用此函数之前使用生成负值的插值,则此函数将不起作用。
p (float, 可选) 每次失真操作(对比度、饱和度等)的概率 – 默认为 0.5。
使用
RandomPhotometricDistort
的示例