Lou1s05 commited on
Commit
2d82de8
·
verified ·
1 Parent(s): 2bdff5e

Add dataset documentation, indexes, and conversion example

Browse files
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ meta/episodes.jsonl filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZJUNLP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,3 +1,47 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - robotics
7
+ - simulation
8
+ - hdf5
9
+ - labvla
10
+ pretty_name: LabEmbodied-Data Beta
11
  ---
12
+
13
+ # LabEmbodied-Data Beta
14
+
15
+ LabEmbodied-Data Beta is a subset of **LabEmbodied-Data**, introduced in [LabVLA](https://arxiv.org/abs/2606.13578). It provides successful laboratory robot demonstrations with multi-view video, language instructions, robot states, actions, and structured annotations.
16
+
17
+ ## Dataset layout
18
+
19
+ ```text
20
+ <robot>/<family>/<case>/ Episode files and task metadata
21
+ meta/ Dataset information and episode indexes
22
+ docs/ Data format reference
23
+ examples/ Optional LeRobot conversion example
24
+ ```
25
+
26
+ Each episode is stored in an H5 file. Use `meta/episodes.jsonl` to locate episodes and their associated metadata. File paths in the index are relative to the dataset root.
27
+
28
+ ## Quick start
29
+
30
+ Read H5 files directly with `h5py`; see the [data format reference](docs/data_format.md) for field definitions and Python usage. Camera videos are embedded in the H5 files.
31
+
32
+ ## Optional LeRobot export
33
+
34
+ The example exports states, actions, language, and RGB videos to LeRobot v3.0 using LeRobot 0.4.4. Run from the dataset root in a Python 3.10+ environment:
35
+
36
+ ```bash
37
+ pip install -r examples/requirements.txt
38
+ python examples/convert_to_lerobot.py \
39
+ --source . --out ../labembodied-ur5e-lerobot \
40
+ --repo-id local/labembodied-ur5e --robot ur5e --max-episodes 2
41
+ ```
42
+
43
+ Omit `--max-episodes` to export all episodes for the selected robot. Joint values and column order are preserved. Videos are decoded and re-encoded; other annotations remain in the H5 files. The output includes `meta/source_episodes.jsonl` to map LeRobot indices to the original episode IDs. Nothing is uploaded.
44
+
45
+ ## License
46
+
47
+ [MIT](LICENSE).
docs/data_format.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data format
2
+
3
+ ## Episode files and indexes
4
+
5
+ Episodes are grouped by robot, task family, and task configuration:
6
+
7
+ ```text
8
+ <robot>/<family>/<case>/
9
+ dataset/
10
+ episode_XXXX.h5
11
+ meta/episode.jsonl
12
+ meta/randomization_episodes.jsonl
13
+ resolved_config.yaml
14
+ results/
15
+ ```
16
+
17
+ - `meta/episodes.jsonl` lists episodes, unique `episode_id` values, H5 paths, instructions, and associated files.
18
+ - `meta/cases.jsonl` lists task configurations and their metadata files.
19
+ - `meta/info.json` contains dataset information and current statistics.
20
+
21
+ Index paths are relative to the dataset root. Episode numbers are local to each task configuration and may be non-consecutive. Use the global index to enumerate files.
22
+
23
+ For associated annotations, match `hdf5_path` or `meta.episode_index` in randomization records and `h5_episode_index` in result records. Task configurations are available as `resolved_config.yaml`.
24
+
25
+ ## H5 fields
26
+
27
+ Read array shapes, column names, camera names, and frame rate from each file. Below, `T` is the frame count, `D` the selected joint-state dimension, `J` the full joint-state dimension, `K` the object count, `C` the camera count, and `S` the subgoal count.
28
+
29
+ | Field | Description |
30
+ |---|---|
31
+ | `agent_pose` | `(T, D)` joint states; columns are described by `agent_pose_names` and the associated index arrays. |
32
+ | `actions` | `(T, D)` joint-position targets. |
33
+ | `joint_positions` | `(T, J)` joint states, with columns described by `joint_position_names`. |
34
+ | `ee_pose`, `ee_pose_valid` | End-effector poses and validity flags; see `ee_pose_names` and `ee_frame`. |
35
+ | `camera_*_rgb` | One-dimensional `uint8` arrays containing H.264 MP4 video bytes. |
36
+ | `language_instruction`, `subtask_instructions` | Episode and subtask instructions. |
37
+ | `step_index` | `(T,)` workflow-stage indices; `-1` marks transition frames. |
38
+ | `object_positions`, `object_orientations`, `object_names` | Object poses and names. Quaternion order is given by the `quaternion_order` attribute. |
39
+ | `bboxes_2d`, `bbox_visibility`, `bbox_camera_names` | `(T, K, C, 4)` image-space boxes, visibility flags, and camera-axis names. |
40
+ | `subgoals/frame_idx`, `subgoals/camera_names`, `subgoals/images_png` | Zero-based frame indices, camera names, and an `(S, C)` grid of PNG byte arrays. |
41
+
42
+ `actions[t]` contains the next recorded joint state; the final target is the measured state at episode end. Read the column names and gripper indices when interpreting joint values.
43
+
44
+ Video bytes must be decoded before accessing images. OpenCV returns BGR images; convert them to RGB before use. Use the H5 `fps` and `frame_count` attributes for timing and length.
45
+
46
+ ## Read an episode
47
+
48
+ ```python
49
+ import json
50
+ from pathlib import Path
51
+
52
+ import h5py
53
+
54
+ root = Path(".")
55
+ with (root / "meta/episodes.jsonl").open() as index:
56
+ item = json.loads(next(index))
57
+
58
+ with h5py.File(root / item["hdf5_path"], "r") as episode:
59
+ states = episode["agent_pose"][()]
60
+ actions = episode["actions"][()]
61
+ instruction = episode["language_instruction"].asstr()[()]
62
+ ```
63
+
64
+ For an optional LeRobot export with video decoding, see [convert_to_lerobot.py](../examples/convert_to_lerobot.py) and the command in the [README](../README.md).
examples/convert_to_lerobot.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Export LabEmbodied-Data H5 episodes to a local LeRobot v3.0 dataset.
2
+
3
+ Requires LeRobot 0.4.4. Exports joint states, joint-position targets, language,
4
+ and RGB videos. Additional annotations remain available in the source H5 files.
5
+ """
6
+
7
+ import argparse
8
+ from contextlib import ExitStack, contextmanager
9
+ from copy import deepcopy
10
+ import json
11
+ from pathlib import Path
12
+ import tempfile
13
+
14
+ import cv2
15
+ import h5py
16
+ import numpy as np
17
+
18
+
19
+ def select_episodes(source, robot, limit):
20
+ selected = []
21
+ with (source / "meta/episodes.jsonl").open(encoding="utf-8") as index:
22
+ for line in index:
23
+ item = json.loads(line)
24
+ if item["robot_type"] == robot and item["success"]:
25
+ selected.append(item)
26
+ if limit is not None and len(selected) == limit:
27
+ break
28
+ if not selected:
29
+ raise ValueError(f"No successful episodes found for robot {robot!r}")
30
+ return selected
31
+
32
+
33
+ def episode_layout(episode, robot):
34
+ """Read and validate the state, action, video, and timing contract."""
35
+ if episode.attrs["robot_type"] != robot or not episode.attrs["episode_success"]:
36
+ raise ValueError(f"Unexpected robot or unsuccessful episode: {episode.filename}")
37
+ count = int(episode.attrs["frame_count"])
38
+ fps = float(episode.attrs["fps"])
39
+ if count <= 0 or fps <= 0 or not fps.is_integer():
40
+ raise ValueError("Expected a nonempty episode with an integer frame rate")
41
+ states, actions = episode["agent_pose"], episode["actions"]
42
+ if states.ndim != 2 or states.shape != actions.shape or states.shape[0] != count:
43
+ raise ValueError("States and joint-position targets must have matching (T, D) shapes")
44
+ names = episode["agent_pose_names"].asstr()[()].tolist()
45
+ if len(names) != states.shape[1]:
46
+ raise ValueError("Joint names do not match the state dimension")
47
+ features = {
48
+ "observation.state": {"dtype": "float32", "shape": states.shape[1:], "names": names},
49
+ "action": {"dtype": "float32", "shape": actions.shape[1:], "names": names},
50
+ }
51
+ cameras = sorted(key for key in episode if key.startswith("camera_") and key.endswith("_rgb"))
52
+ if not cameras:
53
+ raise ValueError("No camera videos found")
54
+ for camera in cameras:
55
+ video = episode[camera]
56
+ shape = tuple(int(value) for value in video.attrs["image_shape"])
57
+ if len(shape) != 3:
58
+ raise ValueError(f"Expected a three-dimensional image shape: {camera}")
59
+ layout = video.attrs["image_layout"]
60
+ if layout == "HWC":
61
+ shape = (shape[2], shape[0], shape[1])
62
+ elif layout != "CHW":
63
+ raise ValueError(f"Unsupported image layout: {layout}")
64
+ if (
65
+ shape[0] != 3
66
+ or int(video.attrs["frame_count"]) != count
67
+ or float(video.attrs["fps"]) != fps
68
+ ):
69
+ raise ValueError(f"Video layout or timing mismatch: {camera}")
70
+ features[f"observation.images.{camera}"] = {
71
+ "dtype": "video", "shape": shape, "names": ["channels", "height", "width"],
72
+ }
73
+ return int(fps), features, cameras
74
+
75
+
76
+ @contextmanager
77
+ def open_video(video, path):
78
+ path.write_bytes(video[()].tobytes())
79
+ capture = cv2.VideoCapture(str(path))
80
+ try:
81
+ if not capture.isOpened():
82
+ raise ValueError(f"Cannot open video: {video.name}")
83
+ yield capture
84
+ finally:
85
+ capture.release()
86
+
87
+
88
+ def export(source, output, repo_id, robot, limit):
89
+ # Import lazily so --help does not require the full LeRobot installation.
90
+ from lerobot.datasets.lerobot_dataset import LeRobotDataset
91
+
92
+ items = select_episodes(source, robot, limit)
93
+ with h5py.File(source / items[0]["hdf5_path"], "r") as episode:
94
+ fps, features, cameras = episode_layout(episode, robot)
95
+ dataset = LeRobotDataset.create(
96
+ repo_id=repo_id, root=output, fps=fps, features=deepcopy(features),
97
+ robot_type=robot, use_videos=True, video_backend="pyav",
98
+ vcodec="h264", image_writer_threads=4, encoder_threads=2,
99
+ )
100
+ try:
101
+ # LeRobot assigns consecutive episode indices; retain the source IDs here.
102
+ with (output / "meta/source_episodes.jsonl").open("w", encoding="utf-8") as mapping:
103
+ for episode_index, item in enumerate(items):
104
+ print(f"[{episode_index + 1}/{len(items)}] {item['episode_id']}", flush=True)
105
+ with h5py.File(source / item["hdf5_path"], "r") as episode:
106
+ if episode_layout(episode, robot) != (fps, features, cameras):
107
+ raise ValueError("Export each robot, frame rate, and feature layout separately")
108
+ states = np.asarray(episode["agent_pose"], dtype=np.float32)
109
+ actions = np.asarray(episode["actions"], dtype=np.float32)
110
+ task = episode["language_instruction"].asstr()[()]
111
+ with tempfile.TemporaryDirectory(prefix="labembodied-") as directory, ExitStack() as stack:
112
+ videos = {
113
+ camera: stack.enter_context(open_video(episode[camera], Path(directory) / f"{camera}.mp4"))
114
+ for camera in cameras
115
+ }
116
+ for frame_index in range(len(states)):
117
+ frame = {
118
+ "observation.state": states[frame_index],
119
+ "action": actions[frame_index],
120
+ "task": task,
121
+ }
122
+ for camera, capture in videos.items():
123
+ ok, bgr = capture.read()
124
+ key = f"observation.images.{camera}"
125
+ c, h, w = features[key]["shape"]
126
+ if not ok or bgr.shape != (h, w, c):
127
+ raise ValueError(f"Missing or invalid frame {frame_index} in {camera}")
128
+ frame[key] = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)
129
+ dataset.add_frame(frame)
130
+ for camera, capture in videos.items():
131
+ if capture.read()[0]:
132
+ raise ValueError(f"Extra video frames in {camera}")
133
+ dataset.save_episode(parallel_encoding=False)
134
+ mapping.write(json.dumps({
135
+ "episode_index": episode_index,
136
+ "source_episode_id": item["episode_id"],
137
+ "source_hdf5_path": item["hdf5_path"],
138
+ }) + "\n")
139
+ mapping.flush()
140
+ finally:
141
+ try:
142
+ dataset.finalize()
143
+ finally:
144
+ dataset.stop_image_writer()
145
+ print(f"Saved {len(items)} episodes to {output}")
146
+
147
+
148
+ def main():
149
+ parser = argparse.ArgumentParser(description=__doc__)
150
+ parser.add_argument("--source", type=Path, default=Path("."), help="Raw dataset root (default: current directory)")
151
+ parser.add_argument("--out", type=Path, required=True, help="New output directory; must not already exist")
152
+ parser.add_argument("--repo-id", required=True, help="LeRobot dataset ID, e.g. local/labembodied-ur5e")
153
+ parser.add_argument("--robot", required=True, help="Robot type in the episode index, e.g. ur5e")
154
+ parser.add_argument("--max-episodes", type=int, help="Limit the export for a small trial; omit to export all selected episodes")
155
+ args = parser.parse_args()
156
+ if args.out.exists():
157
+ parser.error("Output directory already exists; choose a new --out path")
158
+ if args.max_episodes is not None and args.max_episodes <= 0:
159
+ parser.error("--max-episodes must be positive")
160
+ export(args.source, args.out, args.repo_id, args.robot, args.max_episodes)
161
+
162
+
163
+ if __name__ == "__main__":
164
+ main()
examples/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ lerobot==0.4.4
2
+ h5py>=3.10
meta/cases.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
meta/episodes.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00736b30561f50b50652b0c94eec1b120d4c000fe6a0de167c48c7ec56936f11
3
+ size 46690581
meta/info.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "LabEmbodied-Data Beta",
3
+ "format": "robogenesis-raw-h5",
4
+ "format_version": "1.0",
5
+ "license": "MIT",
6
+ "robot_type": "ur5e",
7
+ "episodes": 56314,
8
+ "task_configurations": 629,
9
+ "frames": 69539976,
10
+ "h5_bytes": 366367235420,
11
+ "fps": 20.0,
12
+ "camera_names": [
13
+ "camera_1_rgb",
14
+ "camera_2_rgb",
15
+ "camera_3_rgb"
16
+ ],
17
+ "camera_resolution_hw": [
18
+ 512,
19
+ 512
20
+ ],
21
+ "families": {
22
+ "fastfix_v3": {
23
+ "cases": 257,
24
+ "episodes": 24783,
25
+ "frames": 23941857,
26
+ "h5_bytes": 130018270388
27
+ },
28
+ "lab3_v1": {
29
+ "cases": 372,
30
+ "episodes": 31531,
31
+ "frames": 45598119,
32
+ "h5_bytes": 236348965032
33
+ }
34
+ },
35
+ "indices": {
36
+ "episodes": "meta/episodes.jsonl",
37
+ "cases": "meta/cases.jsonl"
38
+ },
39
+ "native_lerobot": false,
40
+ "repository_name": "LabEmbodied-Data-Beta",
41
+ "release_stage": "beta",
42
+ "data_root": "ur5e",
43
+ "paper": "https://arxiv.org/abs/2606.13578",
44
+ "description": "A subset of LabEmbodied-Data introduced in LabVLA."
45
+ }