@@ -79,6 +79,14 @@ def __init__(self, split_number, width=None, height=None, **kwargs):
79
79
self .split_number = split_number
80
80
81
81
82
+ _VERSION = tfds .core .Version (
83
+ '1.0.0' , experiments = {tfds .core .Experiment .S3 : False })
84
+ _SUPPORTED_VERSIONS = [
85
+ tfds .core .Version (
86
+ '2.0.0' , 'New split API (https://tensorflow.org/datasets/splits)' ),
87
+ ]
88
+
89
+
82
90
class Ucf101 (tfds .core .GeneratorBasedBuilder ):
83
91
"""Ucf101 action recognition dataset.
84
92
@@ -93,35 +101,35 @@ class Ucf101(tfds.core.GeneratorBasedBuilder):
93
101
width = 256 ,
94
102
height = 256 ,
95
103
split_number = 1 ,
96
- version = tfds . core . Version (
97
- '1.0.0' , experiments = { tfds . core . Experiment . S3 : False }) ,
104
+ version = _VERSION ,
105
+ supported_versions = _SUPPORTED_VERSIONS ,
98
106
),
99
107
Ucf101Config (
100
108
name = 'ucf101_1' ,
101
109
description = 'UCF with the action recognition split #1.' ,
102
110
width = None ,
103
111
height = None ,
104
112
split_number = 1 ,
105
- version = tfds . core . Version (
106
- '1.0.0' , experiments = { tfds . core . Experiment . S3 : False }) ,
113
+ version = _VERSION ,
114
+ supported_versions = _SUPPORTED_VERSIONS ,
107
115
),
108
116
Ucf101Config (
109
117
name = 'ucf101_2' ,
110
118
description = 'UCF with the action recognition split #2.' ,
111
119
width = None ,
112
120
height = None ,
113
121
split_number = 2 ,
114
- version = tfds . core . Version (
115
- '1.0.0' , experiments = { tfds . core . Experiment . S3 : False }) ,
122
+ version = _VERSION ,
123
+ supported_versions = _SUPPORTED_VERSIONS ,
116
124
),
117
125
Ucf101Config (
118
126
name = 'ucf101_3' ,
119
127
description = 'UCF with the action recognition split #3.' ,
120
128
width = None ,
121
129
height = None ,
122
130
split_number = 3 ,
123
- version = tfds . core . Version (
124
- '1.0.0' , experiments = { tfds . core . Experiment . S3 : False }) ,
131
+ version = _VERSION ,
132
+ supported_versions = _SUPPORTED_VERSIONS ,
125
133
),
126
134
]
127
135
@@ -186,7 +194,7 @@ def _generate_examples(self, videos_dir, splits_dir, data_list):
186
194
data_list_path_path = os .path .join (splits_dir , data_list )
187
195
with tf .io .gfile .GFile (data_list_path_path , 'r' ) as data_list_file :
188
196
labels_and_paths = data_list_file .readlines ()
189
- for label_and_path in labels_and_paths :
197
+ for label_and_path in sorted ( labels_and_paths ) :
190
198
# The train splits contain not only the filename, but also a digit
191
199
# encoding the label separated by a space, which we ignore.
192
200
label_and_path = label_and_path .strip ().split (' ' )[0 ]
@@ -198,4 +206,4 @@ def _generate_examples(self, videos_dir, splits_dir, data_list):
198
206
logging .error ('Example %s not found' , video_path )
199
207
continue
200
208
# We extract the label from the filename.
201
- yield {'video' : video_path , 'label' : label }
209
+ yield path , {'video' : video_path , 'label' : label }
0 commit comments