@@ -250,10 +250,6 @@ def write_video_info(self) -> None:
250
250
Warning: this function writes info from first episode videos, implicitly assuming that all videos have
251
251
been encoded the same way. Also, this means it assumes the first episode exists.
252
252
"""
253
- # TODO(rcadene): What should we do here?
254
- if "videos" not in self .info :
255
- self .info ["videos" ] = {}
256
-
257
253
for key in self .video_keys :
258
254
if not self .features [key ].get ("info" , None ):
259
255
video_path = self .root / self .get_video_file_path (ep_index = 0 , vid_key = key )
@@ -278,8 +274,6 @@ def create(
278
274
robot_type : str | None = None ,
279
275
features : dict | None = None ,
280
276
use_videos : bool = True ,
281
- # tags: list[str] | None = None,
282
- # license_type: str | None = None,
283
277
) -> "LeRobotDatasetMetadata" :
284
278
"""Creates metadata for a LeRobotDataset."""
285
279
obj = cls .__new__ (cls )
@@ -301,14 +295,11 @@ def create(
301
295
"Dataset features must either come from a Robot or explicitly passed upon creation."
302
296
)
303
297
else :
298
+ # TODO(aliberts, rcadene): implement sanity check for features
304
299
features = {** features , ** DEFAULT_FEATURES }
305
300
306
- # TODO(rcadene): implement sanity check for features
307
-
308
301
obj .tasks , obj .stats , obj .episodes = {}, {}, []
309
302
obj .info = create_empty_dataset_info (CODEBASE_VERSION , fps , robot_type , features , use_videos )
310
- # obj.tags = tags
311
- # obj.license_type = license_type
312
303
if len (obj .video_keys ) > 0 and not use_videos :
313
304
raise ValueError ()
314
305
write_json (obj .info , obj .root / INFO_PATH )
@@ -439,6 +430,7 @@ def __init__(
439
430
440
431
# Unused attributes
441
432
self .image_writer = None
433
+ self .episode_buffer = None
442
434
443
435
self .root .mkdir (exist_ok = True , parents = True )
444
436
@@ -464,9 +456,6 @@ def __init__(
464
456
# Available stats implies all videos have been encoded and dataset is iterable
465
457
self .consolidated = self .meta .stats is not None
466
458
467
- # Create an empty buffer to extend the dataset if required
468
- self .episode_buffer = self ._create_episode_buffer ()
469
-
470
459
def push_to_hub (
471
460
self ,
472
461
tags : list | None = None ,
@@ -704,9 +693,12 @@ def add_frame(self, frame: dict) -> None:
704
693
temporary directory — nothing is written to disk. To save those frames, the 'save_episode()' method
705
694
then needs to be called.
706
695
"""
707
- # TODO(rcadene): Add sanity check for the input, check it's numpy or torch,
696
+ # TODO(aliberts, rcadene): Add sanity check for the input, check it's numpy or torch,
708
697
# check the dtype and shape matches, etc.
709
698
699
+ if self .episode_buffer is None :
700
+ self .episode_buffer = self ._create_episode_buffer ()
701
+
710
702
frame_index = self .episode_buffer ["size" ]
711
703
timestamp = frame ["timestamp" ] if "timestamp" in frame else frame_index / self .fps
712
704
self .episode_buffer ["frame_index" ].append (frame_index )
@@ -930,7 +922,8 @@ def create(
930
922
obj .tolerance_s = tolerance_s
931
923
obj .image_writer = None
932
924
933
- obj .start_image_writer (image_writer_processes , image_writer_threads )
925
+ if image_writer_processes or image_writer_threads :
926
+ obj .start_image_writer (image_writer_processes , image_writer_threads )
934
927
935
928
# TODO(aliberts, rcadene, alexander-soare): Merge this with OnlineBuffer/DataBuffer
936
929
obj .episode_buffer = obj ._create_episode_buffer ()
0 commit comments