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