HDF5转LeRobot_v3.0
更新时间:2026-07-29
简介
把通用 HDF5 具身智能数据集(ALOHA / Mobile ALOHA / RoboMimic 布局)转换为 LeRobot v3.0 数据集,AIHC UDF 封装,依赖 lerobot + h5py + ffmpeg,源读取器可插拔并自动探测 schema,用于把常见 HDF5 采集数据无需逐集写代码地接入标准 LeRobot v3.0 流水线。
功能描述
• 逐行转换:每行处理一个源数据集,源目录为 <input_path>/<input_repoid>(需含至少一个 .hdf5/.h5),产物写到 <output_path>/<input_repoid>
• schema 自动探测:从首个 HDF5 文件自动识别布局;schema_override 可强制指定 aloha/mobile_aloha/robomimic;不匹配抛 UnsupportedHdf5SchemaError
• 视频编码:vcodec 默认 h264(libx264),auto 映射为 h264 避免误选 nvenc
• 元数据可配:default_task 填充缺失任务名,robot_type 写入 v3 元数据;目标已是 v3.0 时默认跳过
算子参数
输入
| 输入 | 含义 |
|---|---|
| input_repoid_col | 数据集逻辑名(string),如 aloha/transfer_cube,写入 v3 元数据并作为子目录名。 |
| input_paths | 源数据集父目录(string);真实源在 <input_paths>/<input_repoid>(递归查找 .hdf5/.h5)。 |
| output_paths | 输出父目录(string);产物写到 <output_paths>/<input_repoid>。 |
输出
| 输出 | 含义 |
|---|---|
| result | 字符串(large_string):"SUCCESS" / "SKIPPED: has already been v3.0" / "Failed: [repo] <ErrorType>: <msg>"。 |
参数
| 参数名称 | 类型 | 默认值 | 描述 | |
|---|---|---|---|---|
| num_workers | int | 4 | 每个数据集的 episode 级进程数,<=1 时内联执行 | |
| vcodec | str | h264 | 视频编码器,默认 h264(libx264);h264_nvenc 需匹配驱动;auto 映射为 h264 | |
| force_conversion | bool | False | 即使输出已是 v3.0 也强制重新转换 | |
| default_task | str | default_task | 源 schema 未提供任务名时,写入每个 episode 的默认任务名 | |
| robot_type | str | unknown | 写入 v3 元数据的自由格式机器人本体标识 | |
| schema_override | str |None | None | 强制指定 schema(aloha/mobile_aloha/robomimic),None 为自动探测 |
调用示例
Python
1from __future__ import annotations
2import os
3import daft
4from daft import col
5from daft.aihc.common.udf import aihc_udf
6from daft.aihc.functions.embodied.convert_hdf5_to_lerobot_v30_udf import ConvertHdf5ToLeRobotV30
7
8if __name__ == "__main__":
9 if os.getenv("DAFT_RUNNER", "native") == "ray":
10 import ray
11 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
12 daft.set_runner_ray()
13 daft.set_execution_config(actor_udf_ready_timeout=6000, min_cpu_per_task=0)
14
15 INPUT_PATH = "/mnt/pfs/hdf5/rm_real_in" # MOCK
16 OUTPUT_PATH = "/mnt/pfs/hdf5/hdf5_v30_out" # MOCK
17 repoid = "robomimic/lift_ph"
18 samples = {
19 "input_repoid_col": [repoid],
20 "input_paths": [INPUT_PATH],
21 "output_paths": [OUTPUT_PATH],
22 }
23 ds = daft.from_pydict(samples)
24 ds = ds.with_column(
25 "result",
26 aihc_udf(
27 ConvertHdf5ToLeRobotV30,
28 construct_args={
29 "num_workers": 4,
30 "vcodec": "h264",
31 "force_conversion": True,
32 "default_task": repoid.rsplit("/", 1)[-1],
33 "robot_type": "unknown",
34 "schema_override": None,
35 },
36 num_cpus=1, concurrency=1, batch_size=1,
37 )(col("input_repoid_col"), col("input_paths"), col("output_paths")),
38 )
39 ds.show()
评价此篇文章
