lerobot
lerobot
¶
Dataset schema for LeRobot dataset V3.0.
LeRobot is a HuggingFace robotics dataset format using: - Parquet files for tabular data (observation.state, action, timestamps) - MP4 videos or embedded PNG bytes for camera observations - JSON metadata files (info.json, stats.json, tasks.jsonl/tasks.parquet)
Reference: https://github.com/huggingface/lerobot
LeRobotDatasetMetadataV30
¶
Metadata handler for LeRobot dataset format V3.0.
This class parses and provides access to LeRobot dataset metadata, including: - info.json: Dataset configuration (version, paths, features, etc.) - tasks.parquet: Task descriptions indexed by task_index - episodes/*.parquet: Per-episode metadata (chunk/file indices, video timestamps)
The LeRobot V3.0 format organizes data in chunks for efficient storage: - Data files: data/chunk-{chunk_index}/episode_{file_index}.parquet - Videos: videos/chunk-{chunk_index}/{video_key}episode.mp4
Attributes:
| Name | Type | Description |
|---|---|---|
dataset_path |
Root path to the LeRobot dataset directory. |
|
info |
Parsed info.json containing dataset configuration. |
|
tasks |
DataFrame of task descriptions from tasks.parquet. |
|
episodes |
Concatenated DataFrame of all episode metadata. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_version
¶
get_data_file_path
¶
Get the path to the parquet data file for a specific episode.
LeRobot stores episode data in chunked parquet files. This method resolves the chunk and file indices from episode metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_index
|
int
|
Index of the episode to locate. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to the episode's parquet data file. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_image_file_path
¶
Get the path to a specific image file.
Used when images are stored as individual files on disk rather than embedded in parquet or encoded as video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_index
|
int
|
Index of the episode. |
required |
image_key
|
str
|
Camera/image stream identifier (e.g., "observation.images.top"). |
required |
frame_index
|
int
|
Frame number within the episode. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to the image file. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_video_file_path
¶
Get the path to a video file for a specific episode and camera.
Videos are stored in chunks similar to data files. This method resolves the chunk and file indices from episode metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_index
|
int
|
Index of the episode. |
required |
video_key
|
str
|
Camera/video stream identifier (e.g., "observation.images.top"). |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to the video file (typically MP4). |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_episode_meta
¶
Get metadata for a specific episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_index
|
int
|
Index of the episode to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Table
|
PyArrow Table row(s) containing the episode's metadata. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_features
¶
Get the feature schema definition from info.json.
Features describe the data columns and their types (e.g., state, action, image, video).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary mapping feature names to their specifications. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_image_keys
¶
Get feature keys for image-type observations.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of image key names (e.g., ["observation.images.top"]). |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_video_keys
¶
Get feature keys for video-type observations.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of video key names (e.g., ["observation.images.top"]). |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_total_episodes
¶
LeRobotDatasetSchemaV30
¶
Bases: DatasetSchema
Dataset schema for converting LeRobot V3.0 datasets to Zarr format.
This schema handles the conversion of LeRobot datasets (stored as parquet files with MP4 videos or PNG images) into the Zarr format. It supports: - Video-based observations (MP4 files decoded at specific timestamps) - Image-based observations (PNG files or embedded bytes in parquet) - State/action vectors from parquet columns - Language instructions from task descriptions
The conversion flow: 1. Load episode data from parquet files 2. Extract frames from videos or load images 3. Map LeRobot features to observation/action keys 4. Apply resizing transforms to images 5. Return data dictionary ready for Zarr storage
Attributes:
| Name | Type | Description |
|---|---|---|
dataset_path |
Root path to the LeRobot dataset directory. |
|
lerobot_metadata |
LeRobotDatasetMetadataV30
|
Metadata handler for accessing dataset structure, loaded lazily on first conversion-time access. |
dataset_type |
String with the dataset type used by the schema (e.g. libero, metaworld, etc.) |
Source code in src/versatil/data/raw/schemas/lerobot.py
lerobot_metadata
property
writable
¶
Raw LeRobot metadata, loaded on first access.
Lazy loading keeps zarr-only workflows independent of the raw dataset directory: when the zarr store already exists, conversion never runs and the raw data does not need to be present.
get_episode_parquet
¶
Load and filter the parquet table rows belonging to one episode.
Source code in src/versatil/data/raw/schemas/lerobot.py
get_episode_videos_frames
¶
Extract all video frames for an episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
int
|
Index of the episode. |
required |
preloaded_episode_table
|
Table
|
Optional pre-loaded episode Table to avoid redundant parquet reads. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[ndarray]]
|
Dictionary mapping video keys to lists of cv2 images (numpy arrays), one per timestep. |
dict[str, list[ndarray]]
|
Returns empty dict if dataset has no video features. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_episode_images
¶
Extract all images for an episode.
Images in LeRobot can be stored in three ways: 1. Embedded as bytes in the parquet file (encoded_image['bytes']) 2. As paths in the parquet file pointing to external files (encoded_image['path']) 3. As separate files on disk (loaded via _get_images_from_filesystem)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
int
|
Index of the episode. |
required |
preloaded_episode_table
|
Table
|
Optional pre-loaded episode Table to avoid redundant parquet reads. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, list[ndarray]]
|
Dictionary mapping image keys to lists of cv2 images (numpy arrays), one per timestep. |
dict[str, list[ndarray]]
|
Returns empty dict if dataset has no image features. |
Source code in src/versatil/data/raw/schemas/lerobot.py
get_episode_language_instructions
¶
Return per-frame language instructions for one episode.
Source code in src/versatil/data/raw/schemas/lerobot.py
extract_episode
¶
Extract and convert a complete episode to zarr format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
int
|
Index of the episode to extract. (currently unused but kept for API consistency with base class). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
Dictionary mapping Zarr keys to numpy arrays ready for storage. |
dict[str, ndarray]
|
Keys correspond to observations and precomputed_actions defined |
dict[str, ndarray]
|
in the DatasetMetadata. |
Source code in src/versatil/data/raw/schemas/lerobot.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
decode_video_frames
¶
Load frames from a video file at specified timestamps using PyAV.
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of RGB numpy arrays (uint8) corresponding to each requested timestamp. |