mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-11 14:49:43 +00:00
Improve loading performance in _absolute_to_relative_idx when remapping indices (#3279)
This commit is contained in:
@@ -105,10 +105,8 @@ class DatasetReader:
|
||||
"""Build absolute-to-relative index mapping from loaded hf_dataset."""
|
||||
self._absolute_to_relative_idx = None
|
||||
if self.episodes is not None and self.hf_dataset is not None:
|
||||
self._absolute_to_relative_idx = {
|
||||
abs_idx.item() if isinstance(abs_idx, torch.Tensor) else abs_idx: rel_idx
|
||||
for rel_idx, abs_idx in enumerate(self.hf_dataset["index"])
|
||||
}
|
||||
indices = self.hf_dataset.data.column("index").to_numpy()
|
||||
self._absolute_to_relative_idx = dict(zip(indices.tolist(), range(len(indices)), strict=True))
|
||||
|
||||
@property
|
||||
def num_frames(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user