快捷方式

RandomPerspective

class torchvision.transforms.RandomPerspective(distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.BILINEAR, fill=0)[原始碼]

以給定的機率對給定影像執行隨機透視變換。如果影像是 torch Tensor,則它應具有 […, H, W] 形狀,其中 … 表示任意數量的前導維度。

引數:
  • distortion_scale (float) – 用於控制失真程度的引數,範圍從 0 到 1。預設為 0.5。

  • p (float) – 影像被變換的機率。預設為 0.5。

  • interpolation (InterpolationMode) – 由 torchvision.transforms.InterpolationMode 定義的所需插值列舉。預設為 InterpolationMode.BILINEAR。如果輸入是 Tensor,則僅支援 InterpolationMode.NEARESTInterpolationMode.BILINEAR。也接受相應的 Pillow 整數常量,例如 PIL.Image.BILINEAR

  • fill (sequencenumber) – 轉換影像外部區域的畫素填充值。預設為 0。如果給定一個數字,則該值分別用於所有波段。

使用 RandomPerspective 的示例

關鍵點上的變換

關鍵點上的變換

轉換圖示

轉換圖示
forward(img)[原始碼]
引數:

img (PIL ImageTensor) – 要進行透視變換的影像。

返回:

隨機變換後的影像。

返回型別:

PIL 影像或張量

static get_params(width: int, height: int, distortion_scale: float) tuple[list[list[int]], list[list[int]]][原始碼]

為隨機透視變換獲取 perspective 的引數。

引數:
  • width (int) – 影像的寬度。

  • height (int) – 影像的高度。

  • distortion_scale (float) – 用於控制失真程度的引數,範圍從 0 到 1。

返回:

包含原始影像的 [左上角、右上角、右下角、左下角] 的列表,包含變換後圖像的 [左上角、右上角、右下角、左下角] 的列表。

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

為初學者和高階開發者提供深入的教程

檢視教程

資源

查詢開發資源並讓您的問題得到解答

檢視資源