Clip Samplers¶
Used to properly sample clips in videos.
Random Clip Samplers¶
- class eztorch.datasets.clip_samplers.RandomClipSampler(clip_duration, speeds=None, jitter_factor=0.0)[source]¶
- Randomly samples clip of size clip_duration from the videos. - Parameters:
- clip_duration ( - Union[- float,- Fraction]) – Duration of a clip.
- speeds ( - Optional[- List[- int]], optional) – If not- None, the list of speeds to randomly apply on clip duration. At each call, \(clip\_duration *= choice(speeds)\).Default:- None- jitter_factor ( - float, optional) – The jitter factor bound to apply on clip duration. At each call, \(clip\_duration *= (1 + \pm rand(0, jitter\_factor))\).Default:- 0.0- class eztorch.datasets.clip_samplers.RandomMultiClipSampler(clip_duration, num_clips, speeds=None, jitter_factor=0.0)[source]¶
- Randomly samples multiple clip of size clip_duration from the videos. - Parameters:
- clip_duration ( - float) – Duration of a clip.
- num_clips ( - int) – Number of clips to sample.
- speeds ( - Optional[- List[- int]], optional) – If not- None, the list of speeds to randomly apply on clip duration. At each call, \(clip\_duration *= choice(speeds)\).Default:- None- jitter_factor ( - float, optional) – The jitter factor bound to apply on clip duration. At each call, \(clip\_duration *= (1 + \pm rand(0, jitter\_factor))\).Default:- 0.0- class eztorch.datasets.clip_samplers.RandomCVRLSampler(clip_duration, speeds=None, jitter_factor=0.0, shuffle=True, power_cdf=1.0, decreasing_cdf=True)[source]¶
- Randomly samples two clip of size clip_duration from the videos. The second clip is sampled after the first one following a Power law for the starting time. - References - Parameters:
- clip_duration ( - Union[- float,- Fraction]) – Duration of a clip.
- speeds ( - Optional[- List[- int]], optional) – If not- None, the list of speeds to randomly apply on clip duration. At each call, \(clip\_duration *= choice(speeds)\).Default:- None- jitter_factor ( - float, optional) – The jitter factor bound to apply on clip duration. At each call, \(clip\_duration *= (1 + \pm rand(0, jitter\_factor))\).Default:- 0.0- shuffle ( - bool, optional) – If- True, shuffle the clip order for the output.Default:- True- power_cdf ( - float, optional) – Power coefficient for the power law.Default:- 1.0- decreasing_cdf ( - bool, optional) – Whether the power law curve is ascending or descending.Default:- True- Deterministic Clip Samplers¶- class eztorch.datasets.clip_samplers.ConstantClipsPerVideoSampler(clip_duration, clips_per_video, augs_per_clip=1)[source]¶
- Evenly splits the video into clips_per_video increments and samples clips of size clip_duration at these increments. - Parameters:
- clip_duration ( - float) – Duration of a clip.
- clips_per_video ( - int) – Number of temporal clips to sample per video.
- augs_per_clip ( - int, optional) – Number of augmentations to be applied on each clip.Default:- 1- class eztorch.datasets.clip_samplers.ConstantClipsWithHalfOverlapPerVideoClipSampler(clip_duration, augs_per_clip=1)[source]¶
- Evenly splits the video into clips_per_video increments and samples clips of size clip_duration at these increments. - Parameters:
- clip_duration ( - float) – Duration of a clip.
- augs_per_clip ( - int, optional) – Number of augmentations to be applied on each clip.Default:- 1- class eztorch.datasets.clip_samplers.MinimumFullCoverageClipSampler(clip_duration, augs_per_clip=1)[source]¶
- Find the minmimum number of clips to cover the full video. - Parameters:
- clip_duration ( - float) – Duration of a clip.
- augs_per_clip ( - int, optional) – Number of augmentations to be applied on each clip.Default:- 1- class eztorch.datasets.clip_samplers.UniformClipSampler(clip_duration, stride=None, backpad_last=False, eps=1e-06)[source]¶
- Evenly splits the video into clips of size clip_duration. 
 - SoccerNet Clip Samplers¶- class eztorch.datasets.clip_samplers.soccernet.SoccerNetClipSampler(data_source, shuffle=False)[source]¶
- Base class for SoccerNet clip samplers. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.SoccerNetClipSamplerDistributedSamplerWrapper(sampler, *args, **kwargs)[source]¶
- Wrapper over - Samplerfor distributed training.- Note - The purpose of this wrapper is to take care of sharding the sampler indices. It is up to the underlying sampler to handle randomness and shuffling. The - shuffleand- seedarguments on this wrapper won’t have any effect.
 - class eztorch.datasets.clip_samplers.soccernet.ActionWindowSoccerNetClipSampler(data_source, window_duration=32.0, offset_action=0.0, shuffle=False)[source]¶
- Sampler windows randomly around actions in SoccerNet videos. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- window_duration ( - float, optional) – Duration of a window.Default:- 32.0- offset_action ( - float, optional) – Minimum offset before and after the action.Default:- 0.0- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.FeatureExtractionSoccerNetClipSampler(data_source, window_duration=2.56, fps=2, shuffle=False)[source]¶
- Sampler windows that slide across the whole video to extract features at a specified fps. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- window_duration ( - float, optional) – Duration of a window.Default:- 2.56- fps ( - int, optional) – fps to extract features.Default:- 2- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.ImagesSoccerNetClipSampler(data_source, images_per_video=None, shuffle=False)[source]¶
- Sampler of images in an ImageSoccerNet dataset. - Parameters:
- data_source ( - ImageSoccerNet) – SoccerNet dataset.
- images_per_video ( - int|- None, optional) – Number of images per video to sample.Default:- None- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.RandomWindowSoccerNetClipSampler(data_source, windows_per_video=50, window_duration=32.0, sample_edges=False, shuffle=False)[source]¶
- Sampler randomly windows in SoccerNet videos. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- windows_per_video ( - int, optional) – Number of windows to sampler per video.Default:- 50- window_duration ( - float, optional) – Duration of a window.Default:- 32.0- sample_edges ( - bool, optional) – Whether to force the sample of edges in the videos. Useful for kick-offs or last second actions.Default:- False- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.SlidingWindowSoccerNetClipSampler(data_source, window_duration=32.0, overlap_window=1.0, shuffle=False)[source]¶
- Sampler windows that slide across the whole video. Possibility to overlap windows. The last window is always between (half_duration - window_duration, window_duration). - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- window_duration ( - float, optional) – Duration of a window.Default:- 32.0- overlap_window ( - float, optional) – Overlap duration between two windows.Default:- 1.0- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.UniformWindowSoccerNetClipSampler(data_source, windows_per_video=50, window_duration=32.0, sample_edges=False, shuffle=False)[source]¶
- Sampler uniformly randomly windows in SoccerNet videos. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- windows_per_video ( - int, optional) – Number of windows to sampler per video.Default:- 50- window_duration ( - float, optional) – Duration of a window.Default:- 32.0- sample_edges ( - bool, optional) – Whether to force the sample of edges in the videos. Useful for kick-offs or last second actions.Default:- False- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.soccernet.UniformWindowWithoutOverlapSoccerNetClipSampler(data_source, windows_per_video=50, window_duration=32.0, sample_edges=False, prevent_resample_edges=True, shuffle=False)[source]¶
- Sampler uniformly randoml windows in SoccerNet videos. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- windows_per_video ( - int, optional) – Number of windows to sampler per video.Default:- 50- window_duration ( - float, optional) – Duration of a window.Default:- 32.0- sample_edges ( - bool, optional) – Whether to force the sample of edges in the videos. Useful for first or last second actions.Default:- False- prevent_resample_edges ( - bool, optional) – Whether to prevent resample of edges. If True, prevent half of the window duration of edges to be sampled again.Default:- True- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- Spot Clip Samplers¶- class eztorch.datasets.clip_samplers.spot.SpotClipSampler(data_source, shuffle=False)[source]¶
- Base class for Spot clip samplers. - Parameters:
- data_source ( - Spot) – Spot dataset.
- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.spot.SpotClipSamplerDistributedSamplerWrapper(sampler, *args, **kwargs)[source]¶
- Wrapper over - Samplerfor distributed training.- Note - The purpose of this wrapper is to take care of sharding the sampler indices. It is up to the underlying sampler to handle randomness and shuffling. The - shuffleand- seedarguments on this wrapper won’t have any effect.
 - class eztorch.datasets.clip_samplers.spot.FeatureExtractionSpotClipSampler(data_source, window_num_frames=16, shuffle=False)[source]¶
- Sampler windows that slide across the whole video to extract features. - Parameters:
- data_source ( - SoccerNet) – SoccerNet dataset.
- window_num_frames ( - float, optional) – Duration of a window.Default:- 16- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.spot.ImagesSpotClipSampler(data_source, images_per_video=None, shuffle=False)[source]¶
- Sampler of images in an ImageSoccerNet dataset. - Parameters:
- data_source ( - Spot) – SoccerNet dataset.
- images_per_video ( - int|- None, optional) – Number of images per video to sample.Default:- None- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.spot.SlidingWindowSpotClipSampler(data_source, window_num_frames=32, overlap_window=1, shuffle=False)[source]¶
- 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). - Parameters:
- data_source ( - Spot) – SoccerNet dataset.
- window_num_frames ( - int, optional) – Duration of a window.Default:- 32- overlap_window ( - int, optional) – Overlap duration between two windows.Default:- 1- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False- class eztorch.datasets.clip_samplers.spot.UniformWindowWithoutOverlapSpotClipSampler(data_source, windows_per_video=50, window_num_frames=32, sample_edges=False, prevent_resample_edges=True, shuffle=False)[source]¶
- Sampler uniformly randoml windows in Spot videos. - Parameters:
- data_source ( - Spot) – Spot dataset.
- windows_per_video ( - int, optional) – Number of windows to sampler per video.Default:- 50- window_num_frames ( - int, optional) – Duration of a window.Default:- 32- sample_edges ( - bool, optional) – Whether to force the sample of edges in the videos. Useful for first or last second actions.Default:- False- prevent_resample_edges ( - bool, optional) – Whether to prevent resample of edges. If True, prevent half of the window duration of edges to be sampled again.Default:- True- shuffle ( - bool, optional) – Whether to shuffle indices.Default:- False