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 幀的 2 個影片,如果
frames_per_clip=5
且step_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, optional) – 一個函式/轉換,它接受 TxHxWxC 影片並傳回轉換後的版本。
download (bool) – 將官方版本的資料集下載到根資料夾。
num_workers (int) – 使用多個 worker 進行 VideoClips 建立
num_download_workers (int) – 使用多進程以加速下載。
output_format (str, optional) – 輸出影片張量的格式(轉換之前)。可以是 “THWC” 或 “TCHW”(預設)。 請注意,在大多數其他工具和數據集中,預設實際上是 “THWC”。
- 回傳值:
一個包含以下條目的 3-tuple
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 is True
且影片檔案已解壓縮。
- 特殊成員: