Failure with StreamingLeRobotDataset

#5
by f3m1 - opened

The program

data = StreamingLeRobotDataset("lerobot/droid_1.0.1")
x = next(iter(data))

Results in the error


IndexError Traceback (most recent call last)
Cell In[9], line 1
----> 1 x = next(iter(data))

File ~/roboworld/.venv/lib/python3.12/site-packages/lerobot/datasets/streaming_dataset.py:376, in StreamingLeRobotDataset.iter(self)
373 backtrack_dataset = idx_to_backtrack_dataset[shard_key] # selects which shard to iterate on
375 try:
--> 376 for frame in self.make_frame(backtrack_dataset):
377 if len(frames_buffer) == self.buffer_size:
378 i = next(buffer_indices_generator) # samples a element from the buffer

File ~/roboworld/.venv/lib/python3.12/site-packages/lerobot/datasets/streaming_dataset.py:498, in StreamingLeRobotDataset.make_frame(self, dataset_iterator)
494 # Some timestamps might not result available considering the episode's boundaries
495 query_timestamps = self._get_query_timestamps(
496 current_ts, self.delta_indices, episode_boundaries_ts
497 )
--> 498 video_frames = self._query_videos(query_timestamps, ep_idx)
500 if self.image_transforms is not None:
501 image_keys = self.meta.camera_keys

File ~/roboworld/.venv/lib/python3.12/site-packages/lerobot/datasets/streaming_dataset.py:554, in StreamingLeRobotDataset._query_videos(self, query_timestamps, ep_idx)
552 root = self.meta.url_root if self.streaming and not self.streaming_from_local else self.root
553 video_path = f"{root}/{self.meta.get_video_file_path(ep_idx, video_key)}"
--> 554 frames = decode_video_frames_torchcodec(
555 video_path, query_ts, self.tolerance_s, decoder_cache=self.video_decoder_cache
556 )
558 item[video_key] = frames.squeeze(0) if len(query_ts) == 1 else frames
560 return item

File ~/roboworld/.venv/lib/python3.12/site-packages/lerobot/datasets/video_utils.py:347, in decode_video_frames_torchcodec(video_path, timestamps, tolerance_s, log_loaded_timestamps, decoder_cache)
345 frame_indices = [round(ts * average_fps) for ts in timestamps]
346 # retrieve frames based on indices
--> 347 frames_batch = decoder.get_frames_at(indices=frame_indices)
349 for frame, pts in zip(frames_batch.data, frames_batch.pts_seconds, strict=True):
350 loaded_frames.append(frame)

File ~/roboworld/.venv/lib/python3.12/site-packages/torchcodec/decoders/_video_decoder.py:368, in VideoDecoder.get_frames_at(self, indices)
358 def get_frames_at(self, indices: torch.Tensor | list[int]) -> FrameBatch:
359 """Return frames at the given indices.
360
361 Args:
(...) 365 FrameBatch: The frames at the given indices.
366 """
--> 368 data, pts_seconds, duration_seconds = core.get_frames_at_indices(
369 self._decoder, frame_indices=indices
370 )
372 return FrameBatch(
373 data=data,
374 pts_seconds=pts_seconds,
375 duration_seconds=duration_seconds,
376 )

File ~/roboworld/.venv/lib/python3.12/site-packages/torchcodec/_core/ops.py:281, in get_frames_at_indices(decoder, frame_indices)
278 else:
279 # Convert list to tensor for dispatch
280 frame_indices = torch.tensor(frame_indices)
--> 281 return _get_frames_at_indices_tensor_input(decoder, frame_indices=frame_indices)

File ~/roboworld/.venv/lib/python3.12/site-packages/torch/_ops.py:819, in OpOverload.call(self, *args, **kwargs)
818 def call(self, /, *args: _P.args, **kwargs: _P.kwargs) -> _T:
--> 819 return self._op(*args, **kwargs)

IndexError: Invalid frame index=3228251 for streamIndex=0; must be less than 149604

Not sure if this is an error on my end.

Sign up or log in to comment