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 (

    Default:) – Duration of a clip.

  • speeds (

    Default:, 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 (

    Default:, 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 (

    Default:) – Duration of a clip.

  • num_clips (

    Default:) – Number of clips to sample.

  • speeds (

    Default:, 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 (

    Default:, 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 (

    Default:) – Duration of a clip.

  • speeds (

    Default:, 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 (

    Default:, 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 (

    Default:, optional) – If True, shuffle the clip order for the output.
    Default: True

  • power_cdf (

    Default:, optional) – Power coefficient for the power law.
    Default: 1.0

  • decreasing_cdf (

    Default:, 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 (

    Default:) – Duration of a clip.

  • clips_per_video (

    Default:) – Number of temporal clips to sample per video.

  • augs_per_clip (

    Default:, 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 (

    Default:) – Duration of a clip.

  • augs_per_clip (

    Default:, 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 (

    Default:) – Duration of a clip.

  • augs_per_clip (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • shuffle (

    Default:, optional) – Whether to shuffle indices.
    Default: False

class eztorch.datasets.clip_samplers.soccernet.SoccerNetClipSamplerDistributedSamplerWrapper(sampler, *args, **kwargs)[source]#

Wrapper over Sampler for 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 shuffle and seed arguments 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 (

    Default:) – SoccerNet dataset.

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 32.0

  • offset_action (

    Default:, optional) – Minimum offset before and after the action.
    Default: 0.0

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 2.56

  • fps (

    Default:, optional) – fps to extract features.
    Default: 2

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • images_per_video (

    Default:, optional) – Number of images per video to sample.
    Default: None

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • windows_per_video (

    Default:, optional) – Number of windows to sampler per video.
    Default: 50

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 32.0

  • sample_edges (

    Default:, optional) – Whether to force the sample of edges in the videos. Useful for kick-offs or last second actions.
    Default: False

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 32.0

  • overlap_window (

    Default:, optional) – Overlap duration between two windows.
    Default: 1.0

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • windows_per_video (

    Default:, optional) – Number of windows to sampler per video.
    Default: 50

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 32.0

  • sample_edges (

    Default:, optional) – Whether to force the sample of edges in the videos. Useful for kick-offs or last second actions.
    Default: False

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • windows_per_video (

    Default:, optional) – Number of windows to sampler per video.
    Default: 50

  • window_duration (

    Default:, optional) – Duration of a window.
    Default: 32.0

  • sample_edges (

    Default:, optional) – Whether to force the sample of edges in the videos. Useful for first or last second actions.
    Default: False

  • prevent_resample_edges (

    Default:, optional) – Whether to prevent resample of edges. If True, prevent half of the window duration of edges to be sampled again.
    Default: True

  • shuffle (

    Default:, 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 (

    Default:) – Spot dataset.

  • shuffle (

    Default:, optional) – Whether to shuffle indices.
    Default: False

class eztorch.datasets.clip_samplers.spot.SpotClipSamplerDistributedSamplerWrapper(sampler, *args, **kwargs)[source]#

Wrapper over Sampler for 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 shuffle and seed arguments 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 (

    Default:) – SoccerNet dataset.

  • window_num_frames (

    Default:, optional) – Duration of a window.
    Default: 16

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • images_per_video (

    Default:, optional) – Number of images per video to sample.
    Default: None

  • shuffle (

    Default:, 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 (

    Default:) – SoccerNet dataset.

  • window_num_frames (

    Default:, optional) – Duration of a window.
    Default: 32

  • overlap_window (

    Default:, optional) – Overlap duration between two windows.
    Default: 1

  • shuffle (

    Default:, 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 (

    Default:) – Spot dataset.

  • windows_per_video (

    Default:, optional) – Number of windows to sampler per video.
    Default: 50

  • window_num_frames (

    Default:, optional) – Duration of a window.
    Default: 32

  • sample_edges (

    Default:, optional) – Whether to force the sample of edges in the videos. Useful for first or last second actions.
    Default: False

  • prevent_resample_edges (

    Default:, optional) – Whether to prevent resample of edges. If True, prevent half of the window duration of edges to be sampled again.
    Default: True

  • shuffle (

    Default:, optional) – Whether to shuffle indices.
    Default: False