File size: 2,598 Bytes
c42c446 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | """Push the local LeRobotDataset to the Hugging Face Hub.
Authenticate first (``hf auth login`` or ``export HF_TOKEN=hf_...``).
Uses :meth:`LeRobotDataset.push_to_hub` so the repo gets a LeRobot
auto-generated dataset card and a version tag.
Usage:
uv run scripts/push_to_hub.py
uv run scripts/push_to_hub.py --repo-id your-org/your-dataset --private
uv run scripts/push_to_hub.py --branch v0.1
"""
import sys
from pathlib import Path
import tyro
sys.path.insert(0, str(Path(__file__).resolve().parent))
from common import LITE_DATASET_REPO_ID # noqa: E402
REPO_ROOT: Path = Path(__file__).resolve().parent.parent
TAGS: list[str] = [
"lerobot",
"humanoid",
"motion-capture",
"motion-tracking",
"berkeley-humanoids",
"lite",
"lafan1",
]
def main(
repo_id: str = LITE_DATASET_REPO_ID,
private: bool = False,
branch: str | None = None,
) -> None:
"""Upload the local dataset to the HF Hub.
Args:
repo_id: Target dataset repo id ``{user_or_org}/{name}``. Must be a
location your authenticated account can write to.
private: If True, create the repo as private.
branch: Optional branch to push to (created from main if missing).
"""
from lerobot.datasets import LeRobotDataset
if not (REPO_ROOT / "meta").exists() or not (REPO_ROOT / "data").exists():
raise SystemExit(
f"Expected meta/ and data/ under {REPO_ROOT}. "
f"Run scripts/retarget.py first."
)
dataset = LeRobotDataset(repo_id=repo_id, root=REPO_ROOT)
print(
f"Uploading {dataset.meta.total_episodes} episodes "
f"({dataset.meta.total_frames} frames @ {dataset.meta.fps} FPS) "
f"→ https://huggingface.co/datasets/{repo_id}"
)
# The dataset root *is* the repo root, so the folder also contains the
# LAFAN1 download cache, venv, build artefacts, etc. ``allow_patterns``
# restricts the upload to dataset content + reproduction sources
# (scripts, pyproject, instructions). ``scripts/*.py`` is intentionally
# not ``scripts/**`` so we don't accidentally publish ``__pycache__/``.
dataset.push_to_hub(
tags=TAGS,
license="cc-by-nc-4.0",
private=private,
branch=branch,
push_videos=False,
allow_patterns=[
"meta/**",
"data/**",
"scripts/*.py",
"pyproject.toml",
"INSTRUCTIONS.md",
],
)
print(f"Done. View at https://huggingface.co/datasets/{repo_id}")
if __name__ == "__main__":
tyro.cli(main)
|