快捷方式

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')[源]

通用 Kinetics 資料集。

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

舉個例子,對於 10 幀和 15 幀的 2 個影片,如果 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 會根據 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, 可選) – 一個函式/轉換,它接收 TxHxWxC 影片並返回轉換後的版本。

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

  • num_workers (int) – 使用多個 worker 建立 VideoClips

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

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

返回:

一個 3 元組,包含以下條目:

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

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

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

返回型別:

元組

丟擲:

RuntimeError – 如果 download True 且影片存檔已解壓。

特殊成員:

__getitem__(idx: int) tuple[torch.Tensor, torch.Tensor, int][源]
引數:

index (int) – 索引

返回:

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

返回型別:

(Any)

文件

訪問全面的 PyTorch 開發者文件

檢視文件

教程

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

檢視教程

資源

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

檢視資源