Skip to content

Commit b85a872

Browse files
scottsfacebook-github-bot
authored andcommitted
[torchcodec] rename deprecated sampler (#906)
Summary: Renaming the old, deprecated sampler to remove any doubt about its status. This code is not documented or part of our release. Reviewed By: NicolasHug Differential Revision: D82962921
1 parent 6f906f4 commit b85a872

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/torchcodec/_samplers/video_clip_sampler.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,12 @@ class IndexBasedSamplerArgs(SamplerArgs):
105105
sample_step: int = 1
106106

107107

108-
class VideoClipSampler(nn.Module):
108+
class DEPRECATED_VideoClipSampler(nn.Module):
109109
"""
110-
VideoClipSampler will do video clip sampling with given video args and sampler args.
111-
The video args contains video related information, frames_per_clip, dimensions etc.
112-
The sampler args can be either time-based or index-based, it will be used to decide clip start time pts or index.
113-
ClipSampling support, random, uniform, periodic, target, keyframe sampling etc.
110+
DEPRECATED: Do not use. The supported samplers are in `torchcodec.samplers`. See:
114111
115-
Args:
116-
video_args (`VideoArgs`): The video args
117-
sampler_args (`SamplerArgs`): The sampler args. Can be TimeBasedSamplerArgs or IndexBasedSamplerArgs
118-
decoder_args (`DecoderArgs`): Decoder args contain value needs for decoder, for example, thread count
119-
120-
Example:
121-
>>> video_args = VideoArgs(desired_width=224, desired_height=224)
122-
>>> time_based_sampler_args = TimeBasedSamplerArgs(sampler_type="random", clips_per_video=1, frames_per_clip=4)
123-
>>> video_decoder_args = DecoderArgs(num_threads=1)
124-
>>> video_clip_sampler = VideoClipSampler(video_args, time_based_sampler_args, decoder_args)
125-
>>> clips = video_clip_sampler(video_data)
126-
clips now contains a list of clip, where clip is a list of frame tensors, each tensor represents a frame image.
112+
* https://docs.pytorch.org/torchcodec/stable/api_ref_torchcodec.html
113+
* https://docs.pytorch.org/torchcodec/stable/generated_examples/decoding/sampling.html
127114
"""
128115

129116
def __init__(

test/test_video_clip_sampler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import pytest
55
import torch
66
from torchcodec._samplers import (
7+
DEPRECATED_VideoClipSampler,
78
IndexBasedSamplerArgs,
89
TimeBasedSamplerArgs,
910
VideoArgs,
10-
VideoClipSampler,
1111
)
1212

1313
from .utils import NASA_VIDEO
@@ -34,7 +34,7 @@ def test_sampler(sampler_args):
3434
torch.manual_seed(0)
3535
desired_width, desired_height = 320, 240
3636
video_args = VideoArgs(desired_width=desired_width, desired_height=desired_height)
37-
sampler = VideoClipSampler(video_args, sampler_args)
37+
sampler = DEPRECATED_VideoClipSampler(video_args, sampler_args)
3838
clips = sampler(NASA_VIDEO.to_tensor())
3939
assert len(clips) == sampler_args.clips_per_video
4040
clip = clips[0]

0 commit comments

Comments
 (0)