mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 10:16:09 +00:00
fix(datasets): remap absolute indices in __getitem__ for filtered datasets
This commit is contained in:
@@ -474,6 +474,8 @@ class LeRobotDataset(torch.utils.data.Dataset):
|
|||||||
if reader.hf_dataset is None:
|
if reader.hf_dataset is None:
|
||||||
# One-shot load after finalize()
|
# One-shot load after finalize()
|
||||||
reader.load_and_activate()
|
reader.load_and_activate()
|
||||||
|
if reader._absolute_to_relative_idx is not None and idx in reader._absolute_to_relative_idx:
|
||||||
|
idx = reader._absolute_to_relative_idx[idx]
|
||||||
return reader.get_item(idx)
|
return reader.get_item(idx)
|
||||||
|
|
||||||
def select_columns(self, column_names: str | list[str]):
|
def select_columns(self, column_names: str | list[str]):
|
||||||
|
|||||||
@@ -436,8 +436,6 @@ def train(cfg: TrainPipelineConfig, accelerator: "Accelerator | None" = None):
|
|||||||
f"Resuming data order at epoch {sampler_state['epoch']}, "
|
f"Resuming data order at epoch {sampler_state['epoch']}, "
|
||||||
f"sample {sampler_state['start_index']}"
|
f"sample {sampler_state['start_index']}"
|
||||||
)
|
)
|
||||||
if dataset.reader._absolute_to_relative_idx is not None:
|
|
||||||
sampler.indices = [dataset.reader._absolute_to_relative_idx[i] for i in sampler.indices]
|
|
||||||
else:
|
else:
|
||||||
shuffle = True
|
shuffle = True
|
||||||
sampler = None
|
sampler = None
|
||||||
|
|||||||
Reference in New Issue
Block a user