快捷方式

Kinetics

class torchvision.datasets.Kinetics(root: Union[str, Path], frames_per_clip: int, num_classes: str = '400', split: str = 'train', frame_rate: Optional[int] = None, step_between_clips: int = 1, transform: Optional[Callable] = None, extensions: Tuple[str, ...] = ('avi', 'mp4'), download: bool = False, num_download_workers: int = 1, num_workers: int = 1, _precomputed_metadata: Optional[Dict[str, Any]] = None, _video_width: int = 0, _video_height: int = 0, _video_min_dimension: int = 0, _audio_samples: int = 0, _audio_channels: int = 0, _legacy: bool = False, output_format: str = 'TCHW')[source]

通用 Kinetics 資料集。

Kinetics-400/600/700 是動作識別影片資料集。該資料集將每個影片視為固定大小影片剪輯的集合,由 frames_per_clip 指定,每個剪輯之間的幀步長由 step_between_clips 給出。

舉例來說,對於分別有 10 幀和 15 幀的兩個影片,如果 frames_per_clip=5step_between_clips=5,則資料集大小將是 (2 + 3) = 5,其中前兩個元素來自影片 1,後三個元素來自影片 2。請注意,我們丟棄了不正好包含 frames_per_clip 個元素的剪輯,因此影片中的並非所有幀都可能被包含。

引數:
  • root (str 或 pathlib.Path) –

    Kinetics 資料集的根目錄。目錄結構應如下所示:.. code

    root/
    ├── split
    │   ├──  class1
    │   │   ├──  vid1.mp4
    │   │   ├──  vid2.mp4
    │   │   ├──  vid3.mp4
    │   │   ├──  ...
    │   ├──  class2
    │   │   ├──   vidx.mp4
    │   │    └── ...
    

    注意:split 引數會自動附加拆分名稱。

  • frames_per_clip (int) – 一個剪輯中的幀數

  • num_classes (int) – 選擇 Kinetics-400(預設)、Kinetics-600 或 Kinetics-700

  • split (str) – 要考慮的資料集拆分;支援 "train"(預設)、"val""test"

  • frame_rate (float) – 如果省略,則為每個剪輯插值不同的幀率。

  • step_between_clips (int) – 每個剪輯之間的幀步長

  • transform (callable, optional) – 一個函式/變換,接收 TxHxWxC 影片並返回變換後的版本。

  • download (bool) – 將資料集的官方版本下載到根資料夾。

  • num_workers (int) – 使用多個工作程序建立 VideoClips

  • num_download_workers (int) – 使用多程序加速下載。

  • output_format (str, optional) – 輸出影片張量(變換前)的格式。可以是 “THWC” 或 “TCHW”(預設)。請注意,在大多數其他工具函式和資料集中,預設實際上是 “THWC”。

返回:

一個包含以下條目的 3 元組

  • video (Tensor[T, C, H, W] 或 Tensor[T, H, W, C]): torch.uint8 張量中的 T 個影片幀

  • audio(Tensor[K, L]): 音訊幀,其中 K 是通道數,L 是 torch.float 張量中的點數

  • label (int): 影片剪輯的類別

返回型別:

元組

丟擲異常:

RuntimeError – 如果 download is True 且影片存檔已解壓,則丟擲。

特殊成員:

__getitem__(idx: int) Tuple[Tensor, Tensor, int][source]
引數:

index (int) – 索引

返回:

樣本和元資料,可選擇由相應的變換進行變換。

返回型別:

(任意)


© Copyright 2017-至今, Torch 貢獻者。

使用 Sphinx 構建,主題由 Read the Docs 提供。

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並解答疑問

檢視資源