-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model and dataset analytics to PyTorchVideo
Summary: For all PTV models, datasets and transforms, adding some analytics to aggregate user metrics Reviewed By: tullie Differential Revision: D28388721 fbshipit-source-id: 9bc45b5a7bda0e3f9d79ad71c79f9eb44d4f3a8f
- Loading branch information
1 parent
6539ed6
commit 124e132
Showing
15 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
|
||
from .labeled_video_dataset import labeled_video_dataset | ||
from typing import Any, Callable, Dict, Optional, Type | ||
|
||
import torch | ||
from pytorchvideo.data.clip_sampling import ClipSampler | ||
|
||
from .labeled_video_dataset import labeled_video_dataset, LabeledVideoDataset | ||
|
||
|
||
""" | ||
Action recognition video dataset for Kinetics-{400,600,700} | ||
<https://deepmind.com/research/open-source/open-source-datasets/kinetics/> | ||
""" | ||
Kinetics = labeled_video_dataset | ||
|
||
|
||
def Kinetics( | ||
data_path: str, | ||
clip_sampler: ClipSampler, | ||
video_sampler: Type[torch.utils.data.Sampler] = torch.utils.data.RandomSampler, | ||
transform: Optional[Callable[[Dict[str, Any]], Dict[str, Any]]] = None, | ||
video_path_prefix: str = "", | ||
decode_audio: bool = True, | ||
decoder: str = "pyav", | ||
) -> LabeledVideoDataset: | ||
""" | ||
A helper function to create ``LabeledVideoDataset`` object for the Kinetics dataset. | ||
Args: | ||
data_path (str): Path to the data. The path type defines how the data | ||
should be read: | ||
* For a file path, the file is read and each line is parsed into a | ||
video path and label. | ||
* For a directory, the directory structure defines the classes | ||
(i.e. each subdirectory is a class). | ||
clip_sampler (ClipSampler): Defines how clips should be sampled from each | ||
video. See the clip sampling documentation for more information. | ||
video_sampler (Type[torch.utils.data.Sampler]): Sampler for the internal | ||
video container. This defines the order videos are decoded and, | ||
if necessary, the distributed split. | ||
transform (Callable): This callable is evaluated on the clip output before | ||
the clip is returned. It can be used for user defined preprocessing and | ||
augmentations to the clips. See the ``LabeledVideoDataset`` class for clip | ||
output format. | ||
video_path_prefix (str): Path to root directory with the videos that are | ||
loaded in ``LabeledVideoDataset``. All the video paths before loading | ||
are prefixed with this path. | ||
decode_audio (bool): If True, also decode audio from video. | ||
decoder (str): Defines what type of decoder used to decode a video. | ||
""" | ||
|
||
torch._C._log_api_usage_once("PYTORCHVIDEO.dataset.Kinetics") | ||
|
||
return labeled_video_dataset( | ||
data_path, | ||
clip_sampler, | ||
video_sampler, | ||
transform, | ||
video_path_prefix, | ||
decode_audio, | ||
decoder, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
|
||
from .labeled_video_dataset import labeled_video_dataset | ||
from typing import Any, Callable, Dict, Optional, Type | ||
|
||
import torch | ||
from pytorchvideo.data.clip_sampling import ClipSampler | ||
|
||
from .labeled_video_dataset import labeled_video_dataset, LabeledVideoDataset | ||
|
||
|
||
""" | ||
Action recognition video dataset for UCF101 | ||
<https://www.crcv.ucf.edu/data/UCF101.php> | ||
""" | ||
Ucf101 = labeled_video_dataset | ||
|
||
|
||
def Ucf101( | ||
data_path: str, | ||
clip_sampler: ClipSampler, | ||
video_sampler: Type[torch.utils.data.Sampler] = torch.utils.data.RandomSampler, | ||
transform: Optional[Callable[[Dict[str, Any]], Dict[str, Any]]] = None, | ||
video_path_prefix: str = "", | ||
decode_audio: bool = True, | ||
decoder: str = "pyav", | ||
) -> LabeledVideoDataset: | ||
""" | ||
A helper function to create ``LabeledVideoDataset`` object for the Ucf101 dataset. | ||
Args: | ||
data_path (str): Path to the data. The path type defines how the data | ||
should be read: | ||
* For a file path, the file is read and each line is parsed into a | ||
video path and label. | ||
* For a directory, the directory structure defines the classes | ||
(i.e. each subdirectory is a class). | ||
clip_sampler (ClipSampler): Defines how clips should be sampled from each | ||
video. See the clip sampling documentation for more information. | ||
video_sampler (Type[torch.utils.data.Sampler]): Sampler for the internal | ||
video container. This defines the order videos are decoded and, | ||
if necessary, the distributed split. | ||
transform (Callable): This callable is evaluated on the clip output before | ||
the clip is returned. It can be used for user defined preprocessing and | ||
augmentations to the clips. See the ``LabeledVideoDataset`` class for clip | ||
output format. | ||
video_path_prefix (str): Path to root directory with the videos that are | ||
loaded in ``LabeledVideoDataset``. All the video paths before loading | ||
are prefixed with this path. | ||
decode_audio (bool): If True, also decode audio from video. | ||
decoder (str): Defines what type of decoder used to decode a video. | ||
""" | ||
|
||
torch._C._log_api_usage_once("PYTORCHVIDEO.dataset.Ucf101") | ||
|
||
return labeled_video_dataset( | ||
data_path, | ||
clip_sampler, | ||
video_sampler, | ||
transform, | ||
video_path_prefix, | ||
decode_audio, | ||
decoder, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters