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 (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) 每個失真操作的機率 (contrast, saturation, ...) – 預設為 0.5。
使用
RandomPhotometricDistort的示例