快捷方式

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 的示例

Transforms v2 入门

Transforms v2 入门

Transforms v2:端到端对象检测/分割示例

Transforms v2:端到端对象检测/分割示例
make_params(flat_inputs: List[Any]) Dict[str, Any][源代码]

用于自定义转换的重写方法。

参见 如何编写您自己的 v2 转换

transform(inpt: Any, params: Dict[str, Any]) Any[源代码]

用于自定义转换的重写方法。

参见 如何编写您自己的 v2 转换

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源