Skip to content

create_zarr_from_lerobot

create_zarr_from_lerobot

Creates a Zarr-based replay buffer dataset from LeRobot datasets.

create_replay_buffer_from_lerobot

create_replay_buffer_from_lerobot(schema, image_frames_per_shard=DEFAULT_IMAGE_FRAMES_PER_SHARD)

Creates a Zarr-based replay buffer from a LeRobot dataset.

Parameters:

Name Type Description Default
schema LeRobotDatasetSchemaV30

LeRobotDatasetSchemaV30 instance.

required
image_frames_per_shard int | None

Number of image frames stored in each shard, or None to disable sharding.

DEFAULT_IMAGE_FRAMES_PER_SHARD

Raises:

Type Description
TypeError

If image_frames_per_shard is not an integer.

ValueError

If image_frames_per_shard is not a positive multiple of the image chunk length.

Source code in src/versatil/data/preprocessing/create_zarr_from_lerobot.py
def create_replay_buffer_from_lerobot(
    schema: LeRobotDatasetSchemaV30,
    image_frames_per_shard: int | None = DEFAULT_IMAGE_FRAMES_PER_SHARD,
) -> None:
    """Creates a Zarr-based replay buffer from a LeRobot dataset.

    Args:
        schema: LeRobotDatasetSchemaV30 instance.
        image_frames_per_shard: Number of image frames stored in each shard, or
            None to disable sharding.

    Raises:
        TypeError: If image_frames_per_shard is not an integer.
        ValueError: If image_frames_per_shard is not a positive multiple of the
            image chunk length.
    """
    total_episodes = schema.lerobot_metadata.get_total_episodes()
    episodes = _iter_lerobot_episodes(
        schema=schema,
        total_episodes=total_episodes,
    )

    create_zarr_replay_buffer(
        schema=schema,
        episodes=episodes,
        total_episodes=total_episodes,
        image_frames_per_shard=image_frames_per_shard,
    )