Skip to content

feat: add LeRobot v3 dataset import support#268

Open
rikunosuke wants to merge 6 commits intomainfrom
feature/lerobot-import-export
Open

feat: add LeRobot v3 dataset import support#268
rikunosuke wants to merge 6 commits intomainfrom
feature/lerobot-import-export

Conversation

@rikunosuke
Copy link
Contributor

@rikunosuke rikunosuke commented Mar 12, 2026

Summary

  • LeRobot v3 データセットを FastLabel ロボティクスプロジェクトにインポートする import_lerobot メソッドを追加
  • pip install fastlabel[robotics] でオプション依存(pandas, pyarrow)をインストール可能に
  • v2 データセットはエラーメッセージで非対応を通知
  • flake8 の E231 誤検知(f-string format spec)を tox.ini で対応
スクリーンショット 2026-03-12 9 33 38

Test plan

  • LeRobot v3 データセットでの import_lerobot 動作確認
  • v2 データセットで適切なエラーメッセージが表示されることを確認
  • pip install fastlabel[robotics] で pandas, pyarrow がインストールされることを確認
  • robotics 依存なしで import 時に適切なエラーが出ることを確認

🤖 Generated with Claude Code

Add import_lerobot method to import LeRobot v3 datasets into FastLabel
robotics projects. Includes optional dependencies (pandas, pyarrow) via
pip install fastlabel[robotics]. v2 datasets are detected and rejected
with an error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines +25 to +27
[project.optional-dependencies]
robotics = ["pandas>=2.0.0", "pyarrow>=14.0.0"]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install fastlabel[robotics] でダウンロードできるようにしています。pandas, pyarrow くらいであれば分ける必要はないと思っているんですが、今後、Lerobot 用のパッケージがなどが入るので、先にこうしています。

Comment on lines +22 to +26
if version == "v2":
raise FastLabelInvalidException(
"LeRobot dataset v2 is not supported. Please convert to v3.",
422,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

まずはメインで使われている v3 をサポートしています。
v2 に関しては、必要今後検討します。

@rikunosuke
Copy link
Contributor Author

こちら、サンプルのために録画した lerobot のデータになります。

sample-realman.zip

Copy link

@kamei-takuma kamei-takuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikunosuke
拝見させていただきました!
ロボット周りがあまりわかってないので、変なこと言ってたら無視してください🙇

localhostに向けて動かして、問題なく動くことは確認しました!
スクリーンショット 2026-03-13 8 02 40

(sdk) kmtkm@193-TakumaKamei fastlabel-python-sdk % python -c "
dquote> from fastlabel.lerobot import common
from pathlib import Path

data_path = Path('sample-realman')

# 1. バージョン検出
print('Version:', common.detect_version(data_path))

# 2. カメラ一覧
for cam_dir, name in common.get_camera_dirs(data_path):
    print(f'Camera: {name}')
"
Version: v3
Camera: cam_high
Camera: cam_left_wrist
Camera: cam_right_wrist
Camera: camera_01
(sdk) kmtkm@193-TakumaKamei fastlabel-python-sdk % python -c "
from fastlabel.lerobot import v3
from pathlib import Path

data_path = Path('sample-realman')

# エピソード一覧
indices = v3.get_episode_indices(data_path)
print('Episodes:', indices)

# 最初のエピソードで ZIP 生成
zip_path = v3.create_episode_zip(data_path, indices[0])
print('ZIP:', zip_path)

# ZIP の中身を確認
import zipfile
with zipfile.ZipFile(zip_path) as zf:
    for name in zf.namelist():
        print(f'  {name}')
"

Episodes: [0]
ZIP: /var/folders/s_/yw3yzchj76vgrqzw9vg24z0h0000gn/T/tmpcuq297nn/episode_000000.zip
  cam_left_wrist.mp4
  cam_right_wrist.mp4
  cam_high.mp4
  episode_000000.json
  camera_01.mp4
(sdk) kmtkm@193-TakumaKamei fastlabel-python-sdk % python -c "
import fastlabel

client = fastlabel.Client()
results = client.import_lerobot(
    project='robotics-task-classification',
    lerobot_data_path='sample-realman',
    episode_indices=[0],
)
print(results)
"
[{'episode': 'episode_000000', 'success': True, 'result': {'id': '7c310bf6-1937-4d48-99cb-04a704317229', 'status': 'running', 'msgCode': 'none', 'userName': '', 'credentialName': 'test', 'createdAt': '2026-03-12T23:01:56.137Z', 'updatedAt': '2026-03-12T23:01:56.137Z'}}]

"action": row["action"].tolist(),
"frame_index": int(row["frame_index"]),
"timestamp": float(row["timestamp"]),
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ロボット詳しくなくてすみません、ここのキー名って決め打ちで大丈夫でしたかね?
observation.stateとかactionとかってロボットが変わっても変わらずあるぜっていうキーなのかどうかがちょっと心配になりました。

もしキーが存在しなかったらKeyエラーが出そうだなとmm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observation.state と action は lerobot の仕様でロボットごとの差異はないので、決め打ちで大丈夫です!
ただ、key がない可能性を考慮できていなかったので、確認をするようにしました🙇

681bb56

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikunosuke
ご対応いただきありがとうございます!

required_keys がなかった場合に [] を返していますが、この場合動画ファイルはあるものの中身が空の JSON が入った ZIP がアップロードされ、success: True として記録されるかと思います。
仕様上 required_keys が必ず存在するとのことなので実害はなさそうですが、
万が一入った時に気づけるよう warning ログを出すなどしてもいいかもとは思いましたが、軽微なので判断はお任せします!

rikunosuke and others added 5 commits March 19, 2026 14:20
The docstring incorrectly described files as nested under an
{episode_name}/ directory, but the implementation places files
at the ZIP root.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Return an empty list when required parquet columns
(observation.state, action, frame_index, timestamp) are missing,
preventing KeyError on datasets from different robot types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use all parts after "observation." joined with "_" for content_name
(e.g. observation.images.top -> images_top) instead of only the last
part. Also replace assert with FastLabelInvalidException for
non-observation camera directories.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rikunosuke
Copy link
Contributor Author

@kamei-takuma
こちら対応したので、レビューをお願いいたします🙇

Copy link

@kamei-takuma kamei-takuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikunosuke
全てご対応いただきありがとうございました!
一件コメントは入れさせていただきましたが、軽微なのでapproveはさせていただきます🙆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants