LeRobot 与 Lance 互转
更新时间:2026-11-23
简介
LeRobot v3.0 数据集与「一帧一行」Lance 表之间的双向转换,由 direction 决定方向,每行一个数据集。正向不解码视频,视频以外链(mp4 地址 + 帧位置)存入 Lance;反向按外链取回视频,重建 LeRobot v3.0 数据集。
功能描述
- to_lance:每帧一行,含 state / action / timestamp / task / 各级下标,每路相机存
<相机>__video_uri/__frame_index/__timestamp三列;数据集信息写进伴生表<名>_meta.lance video_mode="reference"(默认)直接引用源 mp4 路径;upload_bos把 mp4 发布到video_root- from_lance:取回视频并重新编码,写出 LeRobot v3.0 数据集
- 可选登记到数据湖(
lake_catalog)
算子参数
输入
| 输入 | 含义 |
|---|---|
| input_col | to_lance:LeRobot v3.0 根目录(本地 / bosfs);from_lance:Lance 表路径 |
| output_col | to_lance:Lance 表路径;from_lance:LeRobot 输出目录 |
输出
| 输出 | 含义 |
|---|---|
| out | 输出位置(large_string) |
参数
| 参数名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| direction | str | "to_lance" | to_lance / from_lance |
| dataset_name | str | "dataset" | 数据集名 |
| repo_id | str 或 None | None | lerobot repo_id |
| video_root | str 或 None | None | upload_bos 模式的视频发布根(bos:// 或本地目录) |
| video_mode | str | "reference" | reference / upload_bos |
| fps | int 或 None | None | from_lance 时覆盖 fps |
| robot_type | str 或 None | None | from_lance 时覆盖 robot_type |
| use_videos | bool | True | from_lance 时是否写视频 |
| vcodec | str | "h264" | from_lance 视频编码器 |
| encoder_threads | int 或 None | None | from_lance 编码线程数 |
| staging_dir | str 或 None | None | from_lance 从 BOS 取 mp4 的暂存目录 |
| lake_catalog | str 或 None | None | to_lance 完成后登记到的数据湖目录,需配 LAKE_ENDPOINT |
| lake_database | str | "lerobot" | 登记的库名 |
| workflow_id / run_id | str | "" | 血缘上报用的工作流 / 运行 id |
调用示例
Python
1from __future__ import annotations
2
3import os
4
5import daft
6from daft import col
7
8from daft.aihc.common.udf import aihc_udf
9from daft.aihc.functions.embodied.lerobot_lance_udf import LeRobotLanceConverter
10
11if __name__ == "__main__":
12 if os.getenv("DAFT_RUNNER", "native") == "ray":
13 import ray
14 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
15 daft.set_runner_ray()
16 daft.set_execution_config(actor_udf_ready_timeout=6000, min_cpu_per_task=0)
17
18ds = daft.from_pydict({
19 "src": ["/data/lerobot/robomimic_lift"],
20 "dst": ["bos://my-bucket/lake/robomimic_lift.lance"],
21 })
22 ds = ds.with_column(
23 "out",
24 aihc_udf(
25 LeRobotLanceConverter,
26 construct_args={
27 "direction": "to_lance",
28 "dataset_name": "robomimic_lift",
29 "video_mode": "upload_bos",
30 "video_root": "bos://my-bucket/lake/videos",
31 },
32 num_cpus=1,
33 num_gpus=0,
34 concurrency=1,
35 batch_size=1,
36 )(col("src"), col("dst")),
37 )
38 ds.show()
评价此篇文章
