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) – 抖動亮度程度。亮度因子從 [min, max] 中均勻選擇。應為非負數。
contrast (tuple of python:float (min, max), optional) – 抖動對比度程度。對比度因子從 [min, max] 中均勻選擇。應為非負數。
saturation (tuple of python:float (min, max), optional) – 抖動飽和度程度。飽和度因子從 [min, max] 中均勻選擇。應為非負數。
hue (tuple of python:float (min, max), optional) – 抖動色調程度。色調因子從 [min, max] 中均勻選擇。應滿足 -0.5 <= min <= max <= 0.5。要抖動色調,輸入影像的畫素值必須為非負數才能轉換為 HSV 空間;因此,如果您將影像歸一化到負值區間,或在使用此函式之前使用了生成負值的插值方法,則此操作將無效。
p (float, optional) 每個失真操作(對比度、飽和度等)的機率: 預設值為 0.5。
使用
RandomPhotometricDistort的示例