Skip to content

Additional fixes - #754

Merged
aliberts merged 11 commits into
user/aliberts/2025_02_10_dataset_v2.1from
user/aliberts/2025_02_20_additional_fixes
Feb 24, 2025
Merged

aliberts merged 11 commits into
user/aliberts/2025_02_10_dataset_v2.1from
user/aliberts/2025_02_20_additional_fixes

Conversation

@aliberts

@aliberts aliberts commented Feb 20, 2025 •

Copy link
Copy Markdown
Contributor

What this does

  • Improve version compatibility logic
  • Adds a script for removing the "language_instruction" feature which was left in some openX datasets's info.json
  • Remove load_hf_dataset call from save_episode and use np.ndarrays in check_timestamps_sync

How it was tested

Updated the tests accordingly

@aliberts
aliberts marked this pull request as ready for review February 24, 2025 11:09
@aliberts
aliberts requested a review from Cadene February 24, 2025 11:09

@Cadene Cadene left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!! thanks :)

I left a few comments that might need to be addressed before merging.

Looking forward to removing import torch from lerobot_dataset.py

Comment on lines -504 to +508
check_timestamps_sync(self.hf_dataset, self.episode_data_index, self.fps, self.tolerance_s)
timestamps = torch.stack(self.hf_dataset["timestamp"]).numpy()
episode_indices = torch.stack(self.hf_dataset["episode_index"]).numpy()
ep_data_index_np = {k: t.numpy() for k, t in self.episode_data_index.items()}
check_timestamps_sync(timestamps, episode_indices, ep_data_index_np, self.fps, self.tolerance_s)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit worried that this check will take a lot of time for BIG datasets with a few GB of hf_dataset.
Droid is 2GB of hf_dataset, so it's ok-ish.

Should we add an option to disable it int LeRobotDataset init ?
Should we do the check in save_episode only? Why do we need it in init ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's okay to just keep it for now as it's only run in the init and relatively fast still.

Comment on lines 897 to +905
def _save_episode_table(self, episode_buffer: dict, episode_index: int) -> None:
episode_dict = {key: episode_buffer[key] for key in self.hf_features}
ep_dataset = datasets.Dataset.from_dict(episode_dict, features=self.hf_features, split="train")
ep_dataset = embed_images(ep_dataset)
self.hf_dataset = concatenate_datasets([self.hf_dataset, ep_dataset])
self.hf_dataset.set_transform(hf_transform_to_torch)
ep_data_path = self.root / self.meta.get_data_file_path(ep_index=episode_index)
ep_data_path.parent.mkdir(parents=True, exist_ok=True)
write_parquet(ep_dataset, ep_data_path)
ep_dataset.to_parquet(ep_data_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure to understand what this function is doing. Comments could help

concatenate_datasets([self.hf_dataset, ep_dataset]) seems expensive.

Why do we embed images? ep_dataset is not supposed to contain images no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Images are always embedded for the parquet to be portable. This is doing the same operations as before but in a slightly different order.
We used to call _save_episode_table (which embedded the images) then load_hf_dataset in save_episode, which is very slow and expensive. Now I'm just appending the new episode table to the existing hf_dataset. Except that in order to do that I first need to embed the images because we delete episode images in save_episodes and so it would keep the paths to these deleted files, which raises an error when trying to read them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we dont have images, we have videos. I am not sure to understand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For when we do have images (e.g. pusht_image)

Comment on lines +344 to +346
upper_versions = [v for v in hub_versions if v > target_version]
assert len(upper_versions) > 0
raise ForwardCompatibilityError(repo_id, min(upper_versions))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@aliberts
aliberts merged commit 1f21722 into user/aliberts/2025_02_10_dataset_v2.1 Feb 24, 2025
@aliberts
aliberts deleted the user/aliberts/2025_02_20_additional_fixes branch February 24, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants