快捷方式

高斯模糊

class torchvision.transforms.GaussianBlur(kernel_size, sigma=(0.1, 2.0))[source]

使用隨機選擇的高斯模糊對影像進行模糊處理。如果影像是 torch Tensor,則期望其形狀為 […, C, H, W],其中 … 表示至多一個前導維度。

引數:
  • kernel_size (int or sequence) – 高斯核的大小。

  • sigma (float or tuple of python:float (min, max)) – 用於建立執行模糊處理的核的標準差。如果為 float,則 sigma 固定。如果為 float 的 tuple (min, max),則 sigma 在給定範圍內均勻隨機選擇。

返回:

輸入影像的高斯模糊版本。

返回型別:

PIL Image 或 Tensor

使用 GaussianBlur 的示例

變換示例圖

變換示例圖
forward(img: Tensor) Tensor[source]
引數:

img (PIL ImageTensor) – 要進行模糊處理的影像。

返回:

高斯模糊後的影像

返回型別:

PIL Image 或 Tensor

static get_params(sigma_min: float, sigma_max: float) float[source]

為隨機高斯模糊選擇 sigma。

引數:
  • sigma_min (float) – 可選擇用於模糊核的最小標準差。

  • sigma_max (float) – 可選擇用於模糊核的最大標準差。

返回:

用於計算高斯模糊核的標準差。

返回型別:

float

文件

訪問 PyTorch 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源