Skip to content

Commit fe4d17f

Browse files
authored
Rename KineticsVideo to Kinetics400 (#1183)
Also add docs
1 parent 5c0b7f3 commit fe4d17f

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

docs/source/datasets.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,11 @@ USPS
200200
.. autoclass:: USPS
201201
:members: __getitem__
202202
:special-members:
203+
204+
205+
Kinetics-400
206+
~~~~~
207+
208+
.. autoclass:: Kinetics400
209+
:members: __getitem__
210+
:special-members:

references/video_classification/train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def main(args):
139139
if args.distributed:
140140
print("It is recommended to pre-compute the dataset cache "
141141
"on a single-gpu first, as it will be faster")
142-
dataset = torchvision.datasets.KineticsVideo(
142+
dataset = torchvision.datasets.Kinetics400(
143143
traindir,
144144
frames_per_clip=args.clip_len,
145145
step_between_clips=1,
@@ -171,7 +171,7 @@ def main(args):
171171
if args.distributed:
172172
print("It is recommended to pre-compute the dataset cache "
173173
"on a single-gpu first, as it will be faster")
174-
dataset_test = torchvision.datasets.KineticsVideo(
174+
dataset_test = torchvision.datasets.Kinetics400(
175175
valdir,
176176
frames_per_clip=args.clip_len,
177177
step_between_clips=1,

torchvision/datasets/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .sbd import SBDataset
2020
from .vision import VisionDataset
2121
from .usps import USPS
22-
from .kinetics import KineticsVideo
22+
from .kinetics import Kinetics400
2323
from .hmdb51 import HMDB51
2424
from .ucf101 import UCF101
2525

@@ -31,4 +31,4 @@
3131
'Omniglot', 'SBU', 'Flickr8k', 'Flickr30k',
3232
'VOCSegmentation', 'VOCDetection', 'Cityscapes', 'ImageNet',
3333
'Caltech101', 'Caltech256', 'CelebA', 'SBDataset', 'VisionDataset',
34-
'USPS', 'KineticsVideo', 'HMDB51', 'UCF101')
34+
'USPS', 'Kinetics400', 'HMDB51', 'UCF101')

torchvision/datasets/kinetics.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,40 @@
44
from .vision import VisionDataset
55

66

7-
class KineticsVideo(VisionDataset):
7+
class Kinetics400(VisionDataset):
8+
"""
9+
`Kinetics-400 <https://deepmind.com/research/open-source/open-source-datasets/kinetics/>`_
10+
dataset.
11+
12+
Kinetics-400 is an action recognition video dataset.
13+
This dataset consider every video as a collection of video clips of fixed size, specified
14+
by ``frames_per_clip``, where the step in frames between each clip is given by
15+
``step_between_clips``.
16+
17+
To give an example, for 2 videos with 10 and 15 frames respectively, if ``frames_per_clip=5``
18+
and ``step_between_clips=5``, the dataset size will be (2 + 3) = 5, where the first two
19+
elements will come from video 1, and the next three elements from video 2.
20+
Note that we drop clips which do not have exactly ``frames_per_clip`` elements, so not all
21+
frames in a video might be present.
22+
23+
Internally, it uses a VideoClips object to handle clip creation.
24+
25+
Args:
26+
root (string): Root directory of the Kinetics-400 Dataset.
27+
frames_per_clip (int): number of frames in a clip
28+
step_between_clips (int): number of frames between each clip
29+
transform (callable, optional): A function/transform that takes in a TxHxWxC video
30+
and returns a transformed version.
31+
32+
Returns:
33+
video (Tensor[T, H, W, C]): the `T` video frames
34+
audio(Tensor[K, L]): the audio frames, where `K` is the number of channels
35+
and `L` is the number of points
36+
label (int): class of the video clip
37+
"""
38+
839
def __init__(self, root, frames_per_clip, step_between_clips=1, transform=None):
9-
super(KineticsVideo, self).__init__(root)
40+
super(Kinetics400, self).__init__(root)
1041
extensions = ('avi',)
1142

1243
classes = list(sorted(list_dir(root)))

0 commit comments

Comments
 (0)