Skip to content

Commit 8d6f9a6

Browse files
pierrot0copybara-github
authored andcommitted
bair_robot_pushing dataset: S3 version (issue #737).
PiperOrigin-RevId: 257603054
1 parent 6612986 commit 8d6f9a6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

tensorflow_datasets/video/bair_robot_pushing.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class BairRobotPushingSmall(tfds.core.GeneratorBasedBuilder):
5454

5555
VERSION = tfds.core.Version("1.0.0",
5656
experiments={tfds.core.Experiment.S3: False})
57+
SUPPORTED_VERSIONS = [
58+
tfds.core.Version("2.0.0"),
59+
]
60+
# Versions history:
61+
# 2.0.0: S3 (new shuffling, sharding and slicing mechanism).
5762

5863
def _info(self):
5964
# The Bair dataset consist of a sequence of frames (video) with associated
@@ -103,7 +108,8 @@ def _generate_examples(self, filedir):
103108
filepath = os.path.join(filedir, filename)
104109

105110
# For each video inside the file
106-
for example_str in tf.compat.v1.io.tf_record_iterator(filepath):
111+
for i, example_str in enumerate(
112+
tf.compat.v1.io.tf_record_iterator(filepath)):
107113
example = tf.train.SequenceExample.FromString(example_str)
108114

109115
# Merge all frames together
@@ -140,4 +146,7 @@ def _generate_examples(self, filedir):
140146
# {'action': [...], 'image_main': img_frame1, ...}, # Frame 1
141147
# ...,
142148
# ]
143-
yield all_frames
149+
if self.version.implements(tfds.core.Experiment.S3):
150+
yield "%s_%s" % (filepath, i), all_frames
151+
else:
152+
yield all_frames

tensorflow_datasets/video/bair_robot_pushing_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ class BairRobotPushingTest(testing.DatasetBuilderTestCase):
3232
}
3333

3434

35+
class BairRobotPushingS3Test(BairRobotPushingTest):
36+
VERSION = "experimental_latest"
37+
38+
3539
if __name__ == "__main__":
3640
testing.test_main()

0 commit comments

Comments
 (0)