code stringlengths 17 6.64M |
|---|
class DumbDataModule(BaseDataModule):
'Dumb data module for testing models with random data.\n\n Args:\n train: Configuration for the training data to define the loading\n of data and the dataloader.\n val: Configuration for the validation data to define the loading\n of dat... |
class FolderDataModule(BaseDataModule):
'Base datamodule for folder datasets.\n\n Args:\n datadir: Where to save/load the data.\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validation data to def... |
class Hmdb51DataModule(VideoBaseDataModule):
'Datamodule for the HMDB51 dataset.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validat... |
class ImagenetDataModule(FolderDataModule):
'Base datamodule for the Imagenet dataset.\n\n Args:\n datadir: Where to load the data.\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validation data to... |
class Imagenet100DataModule(ImagenetDataModule):
'Base datamodule for the Imagenet100 dataset.\n\n Args:\n datadir: Where to load the data.\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validation... |
class KineticsDataModule(VideoBaseDataModule, ABC):
'Base datamodule for the Kinetics datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration ... |
class Kinetics400DataModule(KineticsDataModule):
'Datamodule for the Kinetics400 datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for t... |
class Kinetics200DataModule(KineticsDataModule):
'Datamodule for the Mini-Kinetics200 dataset.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration f... |
class Kinetics600DataModule(KineticsDataModule):
'Datamodule for the Kinetics600 datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for t... |
class Kinetics700DataModule(KineticsDataModule):
'Datamodule for the Kinetics700 datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for t... |
class SoccerNetDataModule(VideoBaseDataModule, ABC):
'Base datamodule for the SoccerNet datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuratio... |
class ImageSoccerNetDataModule(SoccerNetDataModule):
'Base datamodule for the SoccerNet image datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Config... |
class SpotDataModule(VideoBaseDataModule, ABC):
'Base datamodule for the SoccerNet datasets.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for... |
class STL10DataModule(BaseDataModule):
'Datamodule for the STL10 dataset in SSL setting.\n\n Args:\n datadir: Where to save/load the data.\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validation ... |
class TinyImagenetDataModule(ImagenetDataModule):
'Base datamodule for the Tiny Imagenet dataset.\n\n Args:\n datadir: Where to load the data.\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validat... |
class Ucf101DataModule(VideoBaseDataModule):
'Datamodule for the HMDB51 dataset.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, the transforms and the dataloader.\n val: Configuration for the validat... |
class VideoBaseDataModule(BaseDataModule, ABC):
"Abstract class that inherits from BaseDataModule to follow standardized preprocessing for video datamodules.\n\n Args:\n datadir: Path to the data (eg: csv, folder, ...).\n train: Configuration for the training data to define the loading of data, t... |
def _instantiate_decoder_args(decoder_args: (Dict | None), split: str='train') -> None:
for (key, value) in decoder_args.items():
if ((key == 'frame_filter') and (not callable(value))):
decoder_args[key] = get_subsample_fn(decoder_args['frame_filter']['subsample_type'], decoder_args['frame_fil... |
class ConstantClipsPerVideoSampler(ClipSampler):
'Evenly splits the video into clips_per_video increments and samples clips of size clip_duration at these\n increments.\n\n Args:\n clip_duration: Duration of a clip.\n clips_per_video: Number of temporal clips to sample per video.\n augs... |
class ConstantClipsWithHalfOverlapPerVideoClipSampler(ClipSampler):
'Evenly splits the video into clips_per_video increments and samples clips of size clip_duration at these\n increments.\n\n Args:\n clip_duration: Duration of a clip.\n augs_per_clip: Number of augmentations to be applied on e... |
class MinimumFullCoverageClipSampler(ClipSampler):
'Find the minmimum number of clips to cover the full video.\n\n Args:\n clip_duration: Duration of a clip.\n augs_per_clip: Number of augmentations to be applied on each clip.\n '
def __init__(self, clip_duration: float, augs_per_clip: in... |
def compute_jittered_speed(factor: float, speed: int) -> float:
'Compute jittered speed.\n\n Args:\n factor: The jittering factor.\n speed: The speed to jitter.\n\n Returns:\n float: the jitter speed.\n '
min_speed = (speed * (1 - factor))
max_speed = (speed * (1 + factor))
... |
class RandomClipSampler(ClipSampler):
'Randomly samples clip of size clip_duration from the videos.\n\n Args:\n clip_duration: Duration of a clip.\n speeds: If not ``None``, the list of speeds to randomly apply on clip duration. At each call, :math:`clip\\_duration *= choice(speeds)`.\n ji... |
class RandomMultiClipSampler(RandomClipSampler):
'Randomly samples multiple clip of size clip_duration from the videos.\n\n Args:\n clip_duration: Duration of a clip.\n num_clips: Number of clips to sample.\n speeds: If not ``None``, the list of speeds to randomly apply on clip duration. A... |
class RandomCVRLSampler(ClipSampler):
'Randomly samples two clip of size clip_duration from the videos. The second clip is sampled after the first\n one following a Power law for the starting time.\n\n References:\n - https://arxiv.org/abs/2008.03800\n\n Args:\n clip_duration: Duration of a... |
class ActionWindowSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler windows randomly around actions in SoccerNet videos.\n\n Args:\n data_source: SoccerNet dataset.\n window_duration: Duration of a window.\n offset_action: Minimum offset before and after the action.\n shuffle: Wh... |
class _DatasetSamplerWrapper(Dataset):
'Dataset to create indexes from `SoccerNetClipSampler`.'
def __init__(self, sampler: SoccerNetClipSampler) -> None:
self._sampler = sampler
self._sampler_list: Optional[List[Any]] = None
def __getitem__(self, index: int) -> Any:
if (self._sa... |
class SoccerNetClipSamplerDistributedSamplerWrapper(DistributedSampler):
"Wrapper over ``Sampler`` for distributed training.\n\n Note:\n The purpose of this wrapper is to take care of sharding the sampler indices. It is up to the underlying\n sampler to handle randomness and shuffling. The ``shuf... |
class FeatureExtractionSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler windows that slide across the whole video to extract features at a specified fps.\n\n Args:\n data_source: SoccerNet dataset.\n window_duration: Duration of a window.\n fps: fps to extract features.\n shuffl... |
class ImagesSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler of images in an ImageSoccerNet dataset.\n\n Args:\n data_source: SoccerNet dataset.\n images_per_video: Number of images per video to sample.\n shuffle: Whether to shuffle indices.\n '
def __init__(self, data_source: ... |
class RandomWindowSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler randomly windows in SoccerNet videos.\n\n Args:\n data_source: SoccerNet dataset.\n windows_per_video: Number of windows to sampler per video.\n window_duration: Duration of a window.\n sample_edges: Whether to f... |
class SlidingWindowSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler windows that slide across the whole video. Possibility to overlap windows. The last window is always between (half_duration - window_duration, window_duration).\n\n Args:\n data_source: SoccerNet dataset.\n window_duration: D... |
class SoccerNetClipSampler(Sampler, ABC):
'Base class for SoccerNet clip samplers.\n\n Args:\n data_source: SoccerNet dataset.\n shuffle: Whether to shuffle indices.\n '
def __init__(self, data_source: SoccerNet, shuffle: bool=False) -> None:
super().__init__(data_source)
... |
class UniformWindowSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler uniformly randomly windows in SoccerNet videos.\n\n Args:\n data_source: SoccerNet dataset.\n windows_per_video: Number of windows to sampler per video.\n window_duration: Duration of a window.\n sample_edges: W... |
def random_start_subsequences(clip_duration: float=32, video_duration: float=2700, num_clips: int=50, fps: int=25, sample_edges: bool=True, prevent_resample_edges: bool=True, generator: (torch.Generator | None)=None):
'Sammple starting point of clips inside a video uniformly. Prevent overlap.\n\n Args:\n ... |
class UniformWindowWithoutOverlapSoccerNetClipSampler(SoccerNetClipSampler):
'Sampler uniformly randoml windows in SoccerNet videos.\n\n Args:\n data_source: SoccerNet dataset.\n windows_per_video: Number of windows to sampler per video.\n window_duration: Duration of a window.\n sa... |
class _DatasetSamplerWrapper(Dataset):
'Dataset to create indexes from `SpotClipSampler`.'
def __init__(self, sampler: SpotClipSampler) -> None:
self._sampler = sampler
self._sampler_list: Optional[List[Any]] = None
def __getitem__(self, index: int) -> Any:
if (self._sampler_list... |
class SpotClipSamplerDistributedSamplerWrapper(DistributedSampler):
"Wrapper over ``Sampler`` for distributed training.\n\n Note:\n The purpose of this wrapper is to take care of sharding the sampler indices. It is up to the underlying\n sampler to handle randomness and shuffling. The ``shuffle``... |
class FeatureExtractionSpotClipSampler(SpotClipSampler):
'Sampler windows that slide across the whole video to extract features.\n\n Args:\n data_source: SoccerNet dataset.\n window_num_frames: Duration of a window.\n shuffle: Whether to shuffle indices.\n '
def __init__(self, data... |
class ImagesSpotClipSampler(SpotClipSampler):
'Sampler of images in an ImageSoccerNet dataset.\n\n Args:\n data_source: SoccerNet dataset.\n images_per_video: Number of images per video to sample.\n shuffle: Whether to shuffle indices.\n '
def __init__(self, data_source: Spot, imag... |
class SlidingWindowSpotClipSampler(SpotClipSampler):
'Sampler windows that slide across the whole video. Possibility to overlap windows. The last window is always between (half_duration - window_num_frames, window_num_frames).\n\n Args:\n data_source: SoccerNet dataset.\n window_num_frames: Durat... |
class SpotClipSampler(Sampler, ABC):
'Base class for Spot clip samplers.\n\n Args:\n data_source: Spot dataset.\n shuffle: Whether to shuffle indices.\n '
def __init__(self, data_source: Spot, shuffle: bool=False) -> None:
super().__init__(data_source)
self.data_source = d... |
def random_start_subsequences(clip_duration: int=32, video_num_frames: int=2700, num_subsequences: int=50, sample_edges: bool=True, prevent_resample_edges: bool=True, generator: (torch.Generator | None)=None):
possible_start_idx: np.ndarray = np.arange(0, (video_num_frames - clip_duration))
subsequences = [No... |
class UniformWindowWithoutOverlapSpotClipSampler(SpotClipSampler):
'Sampler uniformly randoml windows in Spot videos.\n\n Args:\n data_source: Spot dataset.\n windows_per_video: Number of windows to sampler per video.\n window_num_frames: Duration of a window.\n sample_edges: Whethe... |
def get_collate_fn(name: str) -> Callable:
'Get a Collate function from its name through the _COLLATE_FUNCTIONS dictionary.\n\n Args:\n name: The collate function name.\n\n Raises:\n NotImplementedError: If the name is not supported.\n\n Returns:\n Callable: the collate function\n ... |
def multiple_samples_collate(batch: List[Dict[(str, List[Any])]]) -> Dict[(str, Any)]:
'Collate function for repeated augmentation. Each instance in the batch has more than one sample.\n\n Args:\n batch: Batch of data before collate.\n\n Returns:\n The collated batch.\n '
batch_dict = {... |
class DecoderType(Enum):
PYAV = 'pyav'
TORCHVISION = 'torchvision'
FRAME = 'frame'
DUMB = 'dumb'
|
class DumbSoccerNetVideo(Video):
'DumbSoccerNetVideo is an abstractions for accessing clips based on their start and end time for a video\n where each frame is randomly generated.\n\n Args:\n video_path: The path of the video.\n half_path: The path of the half.\n duration: The duration ... |
class DumbSpotVideo(Video):
'DumbSpotVideo is an abstractions for accessing clips based on their start and end time for a video where\n each frame is randomly generated.\n\n Args:\n video_path: The path of the video.\n fps: The target fps for the video. This is needed to link the frames\n ... |
class FrameSpotVideo(GeneralFrameVideo):
'FrameSpotVideo is an abstractions for accessing clips based on their start and end time for a video where\n each frame is stored as an image.\n\n Args:\n video_path: The path of the video.\n num_frames: The number of frames of the video.\n trans... |
class DictDataset(Dataset):
'Wrapper around a Dataset to have a dictionary as input for models.\n\n Args:\n dataset: dataset to wrap around.\n '
def __init__(self, dataset: Dataset) -> None:
super().__init__()
self.source_dataset = dataset
def __getitem__(self, idx: int) -> ... |
class DictCIFAR10(DictDataset):
'`CIFAR10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ dict dataset.\n\n Args:\n root: Root directory of dataset where directory\n ``cifar-10-batches-py`` exists or will be saved to if download is set to ``True``.\n train: If ``True``, creates dataset... |
class DictCIFAR100(DictDataset):
'`CIFAR100 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ dict dataset.\n\n Args:\n root: Root directory of dataset where directory\n ``cifar-100-batches-py`` exists or will be saved to if download is set to ``True``.\n train: If ``True``, creates data... |
class DumbDataset(Dataset):
'Dumb dataset that always provide random data. Useful for testing models or pipelines.\n\n Args:\n shape: shape of data to generate.\n len_dataset: length of the dataset. Used by dataloaders.\n '
def __init__(self, shape: List[int], len_dataset: int) -> None:
... |
def has_file_allowed_extension(filename: str, extensions: Union[(str, Tuple[(str, ...)])]) -> bool:
'Checks if a file is an allowed extension.\n\n Args:\n filename: Path to a file.\n extensions: Extensions to consider (lowercase).\n\n Returns:\n ``True`` if the filename ends with one of... |
def is_image_file(filename: str) -> bool:
'Checks if a file is an allowed image extension.\n\n Args:\n filename: Path to a file.\n\n Returns:\n ``True`` if the filename ends with a known image extension.\n '
return has_file_allowed_extension(filename, IMG_EXTENSIONS)
|
def find_classes(directory: str) -> Tuple[(List[str], Dict[(str, int)])]:
'Finds the class folders in a dataset.\n\n See :class:`DatasetFolder` for details.\n '
classes = sorted((entry.name for entry in os.scandir(directory) if entry.is_dir()))
if (not classes):
raise FileNotFoundError(f"Cou... |
def make_dataset(directory: str, class_to_idx: Optional[Dict[(str, int)]]=None, extensions: Optional[Union[(str, Tuple[(str, ...)])]]=None, is_valid_file: Optional[Callable[([str], bool)]]=None) -> List[Tuple[(str, int)]]:
'Generates a list of samples of a form (path_to_sample, class).\n\n See :class:`DatasetF... |
class DatasetFolder(VisionDataset):
'A generic data loader.\n\n This default directory structure can be customized by overriding the\n :meth:`find_classes` method.\n\n Args:\n root: Root directory path.\n loader: A function to load a sample given its path.\n extensions: A list of all... |
def pil_loader(path: str) -> Image.Image:
with open(path, 'rb') as f:
img = Image.open(f)
return img.convert('RGB')
|
def accimage_loader(path: str) -> Any:
import accimage
try:
return accimage.Image(path)
except OSError:
return pil_loader(path)
|
def default_loader(path: str) -> Any:
from torchvision import get_image_backend
if (get_image_backend() == 'accimage'):
return accimage_loader(path)
else:
return pil_loader(path)
|
class ImageFolder(DatasetFolder):
'A generic data loader where the images are arranged in this way by default: ::\n\n root/dog/xxx.png\n root/dog/xxy.png\n root/dog/[...]/xxz.png\n\n root/cat/123.png\n root/cat/nsdf3.png\n root/cat/[...]/asd932_.png\n\n This class inhe... |
def create_hmdb51_files_for_frames(folder_files: str, frames_folder: str, split_id: int):
'Create the HMDB51 csv files for frame decoders.\n\n Args:\n folder_files: Path to the original hmdb51 split files.\n frames_folder: Path to the frame folders.\n split_id: The split id.\n\n Raises:... |
class Hmdb51LabeledVideoPaths():
'Pre-processor for Hmbd51 dataset mentioned here - https://serre-lab.clps.brown.edu/resource/hmdb-a-large-\n human-motion-database/\n\n This dataset consists of classwise folds with each class consisting of 3\n folds (splits).\n\n The videos directory is of the for... |
def Hmdb51(data_path: pathlib.Path, clip_sampler: ClipSampler, transform: (Callable[([dict], Any)] | None)=None, video_path_prefix: str='', split_id: int=1, split_type: str='train', decode_audio=True, decoder: str='pyav', decoder_args: DictConfig={}) -> LabeledVideoDataset:
'A helper function to create ``LabeledV... |
def Kinetics(data_path: str, clip_sampler: ClipSampler, transform: Optional[Callable[([Dict[(str, Any)]], Dict[(str, Any)])]]=None, video_path_prefix: str='', decode_audio: bool=True, decoder: str='pyav', decoder_args: DictConfig={}) -> LabeledVideoDataset:
'A helper function to create ``LabeledVideoDataset`` obj... |
def create_video_files_from_folder(folder: str, output_folder: str, output_filename: str='train.csv'):
'Create the csv files for the dataset.\n\n Args:\n folder: Path to the video folder.\n output_folder: Path to the frame folders.\n output_filename: Name of the output csv file.\n\n Rai... |
def create_frames_files_from_folder(folder: str, output_folder: str, output_filename: str='train.csv'):
'Create the dataset csv files for frame decoders.\n\n Args:\n folder: Path to the video folder.\n output_folder: Path to the frame folders.\n output_filename: Name of the output csv file... |
class LabeledVideoDataset(Dataset):
"LabeledVideoDataset handles the storage, loading, decoding and clip sampling for a video dataset. It assumes\n each video is stored as either an encoded video (e.g. mp4, avi) or a frame video (e.g. a folder of jpg, or png)\n\n Args:\n labeled_video_paths: List con... |
def labeled_video_dataset(data_path: str, clip_sampler: ClipSampler, transform: (Callable[([dict[(str, Any)]], dict[(str, Any)])] | None)=None, video_path_prefix: str='', decode_audio: bool=True, decoder: str='pyav', decoder_args: DictConfig={}) -> LabeledVideoDataset:
'A helper function to create ``LabeledVideoD... |
class LabeledVideoPaths():
'LabeledVideoPaths contains pairs of video path and integer index label.\n\n Args:\n paths_and_labels: a list of tuples containing the video\n path and integer label.\n '
@classmethod
def from_path(cls, data_path: str) -> LabeledVideoPaths:
"Fact... |
def load_features(features_dir: (str | Path), video_paths: List[(str | Path)], filename: str, video_zip_prefix: str='', as_tensor: bool=False) -> dict[(int, dict[(int, (np.ndarray | Tensor))])]:
'Load SoccerNet features.\n\n Args:\n features_dir: Directory or zip where the features are stored.\n ... |
def save_features(dataset: Dataset, saving_path: (str | Path), features: dict[(int, dict[(int, Tensor)])], filename: str, make_zip: bool) -> None:
'Save the features, one file per half per match.\n\n Args:\n dataset: Dataset to save the features from.\n saving_path: Path to save the features.\n ... |
def pca_features(features: dict[(int, dict[(int, np.ndarray)])], dim: int, standardize: bool=True, **kwargs):
'Apply PCA on the given SoccerNet features.\n\n Args:\n features: The features to apply PCA on.\n dim: The output dimension of the PCA.\n standardize: Whether to standardize featur... |
class SoccerNetPathHandler():
'Utility class that handles all deciphering and caching of video paths for encoded and frame videos.'
def __init__(self) -> None:
return
def video_from_path(self, decoder: DecoderType, video_path: str, half_path: str, duration: float, fps_video: int, fps: int, num_f... |
class SoccerNetPaths():
'SoccerNetPaths contains dictionaries describing videos from SoccerNet.\n\n Args:\n annotations: A list of dictionaries describing the videos.\n path_prefix: Path prefix to add to video paths.\n task: The SoccerNet task.\n '
@classmethod
def from_path(cl... |
def load_json(fpath: (str | Path)):
'Load a JSON file.\n\n Args:\n fpath: Path to the JSON file.\n\n Returns:\n The JSON content.\n '
with open(fpath) as fp:
return json.load(fp)
|
def parse_ground_truth(truth: dict) -> dict:
'Parse the ground truth labels.\n\n Args:\n truth: The JSON dataset content.\n\n Returns:\n The parsed labels.\n '
label_dict = defaultdict((lambda : defaultdict(list)))
for x in truth:
for e in x['events']:
label_dict... |
def get_predictions(pred: dict, label: (str | None)=None) -> list:
'Get the label predictions.\n\n Args:\n pred: All the predictions.\n label: The label to look for.\n\n Returns:\n The predictions for the label.\n '
flat_pred = []
for x in pred:
for e in x['events']:
... |
def compute_average_precision(pred: list, truth: np.array, tolerance: int=0, min_precision: int=0) -> float:
'Compute the average precision.\n\n Args:\n pred (list): The label predictions.\n truth (np.array): The truth labels.\n tolerance: The frame tolerance.\n min_precision: The m... |
def compute_mAPs(truth: dict, pred: dict, tolerances: list[int]=[0, 1, 2, 4]):
'Compute the mAPs at different tolerances.\n\n Args:\n truth: The truth labels.\n pred: The label predictions.\n tolerances: The tolerances to compute the mAPs.\n\n Returns:\n The computed mAPs.\n '... |
def load_features(features_dir: (str | Path), video_paths: List[(str | Path)], filename: str, video_zip_prefix: str='', as_tensor: bool=False) -> dict[(int, dict[(int, (np.ndarray | Tensor))])]:
'Load spot features.\n\n Args:\n features_dir: Directory or zip where the features are stored.\n video... |
def save_features(dataset: Dataset, saving_path: (str | Path), features: dict[(int, dict[(int, Tensor)])], filename: str, make_zip: bool) -> None:
'Save the features, one file per video.\n\n Args:\n dataset: Dataset to save the features from.\n saving_path: Path to save the features.\n fea... |
def pca_features(features: dict[(int, dict[(int, np.ndarray)])], dim: int, standardize: bool=True, **kwargs):
'Apply PCA on the given Spot features.\n\n Args:\n features: The features to apply PCA on.\n dim: The output dimension of the PCA.\n standardize: Whether to standardize features be... |
class SpotDatasets(Enum):
TENNIS = 'tennis'
FS_COMP = 'fs_comp'
FS_PERF = 'fs_perf'
|
def initialize_predictions(dataset: Dataset, max_video_index: int, min_video_index: int, device: str='cpu') -> Dict[(int, Dict[(int, Tensor)])]:
'Initialize predictions for videos that have indexes between [min_video_index, max_video_index].\n\n Args:\n dataset: The dataset that contains the videos.\n ... |
def aggregate_and_filter_clips(class_preds: Tensor, frames: Tensor, num_frames: Tensor, video_indexes: Tensor, max_video_index: Tensor, min_video_index: Tensor) -> (Tuple[Tensor] | None):
'Aggregate and filter only clips that have indexes between [min_video_index, max_video_index]. If none have\n been kept, re... |
def add_clip_prediction(predictions: Dict[(int, Dict[(int, Tensor)])], class_preds: Tensor, frames: Tensor, video_index: int, merge_predictions_type: str='max') -> None:
'Add the given predictions of classes of the particular timestamps of a video to the stored predictions.\n\n Args:\n predictions: Curr... |
def add_clips_predictions(predictions: Dict[(int, Dict[(int, Tensor)])], class_preds: Tensor, frames: Tensor, num_frames: Tensor, video_indexes: Tensor, remove_frames_predictions: (int | Tensor)=0, merge_predictions_type: str='max') -> None:
'Add the given predictions of classes of the particular timestamps of th... |
def postprocess_spotting_video_predictions(predictions: Tensor, NMS_args: Dict[(Any, Any)], dataset: SpotDatasets=SpotDatasets.TENNIS) -> List[Dict[(str, Any)]]:
'Postprocess the half predictions for action spotting.\n\n Args:\n predictions: The half predictions.\n half_id: The id of the half.\n ... |
def save_spotting_predictions(predictions: Dict[(str, Any)], saving_path: (str | Path), dataset: Dataset, NMS_args: Dict[(Any, Any)]) -> None:
'Save the predictions for spotting.\n\n Args:\n predictions: The predictions to save as a dictionary following this format:\n ```\n predict... |
def save_raw_spotting_predictions(predictions: Dict[(str, Any)], saving_path: (str | Path), make_zip: bool=True) -> None:
'Save the raw predictions for spotting.\n\n Args:\n predictions: The predictions to save.\n saving_path: Path to the saving directory.\n make_zip: Whether to make a zip... |
def load_raw_spotting_predictions(saved_path: (Path | str), video_indexes: List[int], device: Any='cpu') -> Dict[(int, Dict[(int, Tensor)])]:
'Load the raw predictions for spotting.\n\n Args:\n saved_path: Where the predictions are saved.\n video_indexes: Indexes of the video to load.\n de... |
def merge_predictions(saving_path: (str | Path), saved_paths: List[(str | Path)], video_indexes: List[int], kind_merge: str='average', device: Any='cpu', make_zip: bool=True):
"Merge several predictions for spotting.\n\n Args:\n saving_path: The path to save the predictions.\n saved_paths: Paths ... |
class SpotPathHandler():
'Utility class that handles all deciphering and caching of video paths for encoded and frame videos.'
def __init__(self) -> None:
return
def video_from_path(self, decoder: DecoderType, video_path: str, num_frames: int, **kwargs) -> Video:
'Retrieve a video from t... |
def process_event(events: dict[(str, Any)], labels_dictionary: dict[(str, int)]):
'Process event from spots dictionary.\n\n Args:\n annotation: The annotation to process.\n labels_dictionary: Labels actions to int.\n\n Returns:\n The processed annotation.\n '
new_annotation = {}
... |
class SpotPaths():
'SpotPaths contains dictionaries describing videos from SoccerNet.\n\n Args:\n annotations: A list of dictionaries describing the videos.\n path_prefix: Path prefix to add to video paths.\n '
@classmethod
def from_path(cls, data_path: str, path_prefix: str='', datas... |
def create_ucf101_files_for_frames(folder_files: str, frames_folder: str):
'Create the UCF101 csv files for frame decoders.\n\n Args:\n folder_files: Path to the original ucf101 split files.\n frames_folder: Path to the frame folders.\n\n Raises:\n ImportError: If pandas is not installe... |
class Ucf101LabeledVideoPaths():
'Pre-processor for Ucf101 dataset mentioned here - https://www.crcv.ucf.edu/data/UCF101.php.\n\n This dataset consists of classwise folds with each class consisting of 3\n folds (splits).\n\n The videos directory is of the format,\n video_dir_path/class_x/<some... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.