Instructions to use lcccluck/mujoco-lerobot-train with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use lcccluck/mujoco-lerobot-train with LeRobot:
- Notebooks
- Google Colab
- Kaggle
Upload mujoco_lerobot_train
Browse files- README.md +11 -17
- common.py +2 -43
- upload_to_hf.sh +2 -2
README.md
CHANGED
|
@@ -59,7 +59,6 @@ See:
|
|
| 59 |
- `collect_dataset.py`: collect a MuJoCo pick-place dataset in LeRobot format
|
| 60 |
- `viz_dataset.py`: open `lerobot-dataset-viz` for the configured dataset
|
| 61 |
- `train_policy.py`: Python entry that reads config and launches training
|
| 62 |
-
- `train_policy.sh`: native shell entry that ends with a raw `lerobot-train`
|
| 63 |
- `eval_policy.py`: closed-loop MuJoCo evaluation using the trained policy
|
| 64 |
- `common.py`: shared minimal implementation
|
| 65 |
- `config.json`: all parameters
|
|
@@ -69,7 +68,6 @@ See:
|
|
| 69 |
- `collect_dataset.py`:采集 MuJoCo 抓取放置数据,并写成 LeRobot 标准格式
|
| 70 |
- `viz_dataset.py`:调用 `lerobot-dataset-viz` 可视化当前数据集
|
| 71 |
- `train_policy.py`:读取配置后启动训练
|
| 72 |
-
- `train_policy.sh`:原生 shell 训练入口,最终直接执行 `lerobot-train`
|
| 73 |
- `eval_policy.py`:在 MuJoCo 中闭环评估训练好的策略
|
| 74 |
- `common.py`:公共最小实现
|
| 75 |
- `config.json`:全部参数
|
|
@@ -80,50 +78,46 @@ Activate your environment first:
|
|
| 80 |
|
| 81 |
```bash
|
| 82 |
conda activate lerobot
|
|
|
|
| 83 |
```
|
| 84 |
|
| 85 |
## 运行
|
| 86 |
|
| 87 |
-
先激活环境:
|
| 88 |
|
| 89 |
```bash
|
| 90 |
conda activate lerobot
|
|
|
|
| 91 |
```
|
| 92 |
|
| 93 |
Collect dataset:
|
| 94 |
|
| 95 |
```bash
|
| 96 |
-
python
|
| 97 |
```
|
| 98 |
|
| 99 |
Visualize dataset:
|
| 100 |
|
| 101 |
```bash
|
| 102 |
-
python
|
| 103 |
```
|
| 104 |
|
| 105 |
Train with the Python entry:
|
| 106 |
|
| 107 |
```bash
|
| 108 |
-
python
|
| 109 |
-
```
|
| 110 |
-
|
| 111 |
-
Train with the native shell entry:
|
| 112 |
-
|
| 113 |
-
```bash
|
| 114 |
-
bash /Users/liuchu/codes/robot/mujoco_lerobot_train/train_policy.sh
|
| 115 |
```
|
| 116 |
|
| 117 |
Closed-loop MuJoCo evaluation:
|
| 118 |
|
| 119 |
```bash
|
| 120 |
-
python
|
| 121 |
```
|
| 122 |
|
| 123 |
闭环 MuJoCo 评估:
|
| 124 |
|
| 125 |
```bash
|
| 126 |
-
python
|
| 127 |
```
|
| 128 |
|
| 129 |
## Config
|
|
@@ -165,19 +159,19 @@ huggingface-cli login
|
|
| 165 |
Then upload this folder:
|
| 166 |
|
| 167 |
```bash
|
| 168 |
-
bash /
|
| 169 |
```
|
| 170 |
|
| 171 |
Private repo:
|
| 172 |
|
| 173 |
```bash
|
| 174 |
-
HF_PRIVATE=1 bash /
|
| 175 |
```
|
| 176 |
|
| 177 |
Dataset repo instead of model repo:
|
| 178 |
|
| 179 |
```bash
|
| 180 |
-
HF_REPO_TYPE=dataset bash /
|
| 181 |
```
|
| 182 |
|
| 183 |
Ignored during upload:
|
|
|
|
| 59 |
- `collect_dataset.py`: collect a MuJoCo pick-place dataset in LeRobot format
|
| 60 |
- `viz_dataset.py`: open `lerobot-dataset-viz` for the configured dataset
|
| 61 |
- `train_policy.py`: Python entry that reads config and launches training
|
|
|
|
| 62 |
- `eval_policy.py`: closed-loop MuJoCo evaluation using the trained policy
|
| 63 |
- `common.py`: shared minimal implementation
|
| 64 |
- `config.json`: all parameters
|
|
|
|
| 68 |
- `collect_dataset.py`:采集 MuJoCo 抓取放置数据,并写成 LeRobot 标准格式
|
| 69 |
- `viz_dataset.py`:调用 `lerobot-dataset-viz` 可视化当前数据集
|
| 70 |
- `train_policy.py`:读取配置后启动训练
|
|
|
|
| 71 |
- `eval_policy.py`:在 MuJoCo 中闭环评估训练好的策略
|
| 72 |
- `common.py`:公共最小实现
|
| 73 |
- `config.json`:全部参数
|
|
|
|
| 78 |
|
| 79 |
```bash
|
| 80 |
conda activate lerobot
|
| 81 |
+
cd /Users/liuchu/codes/robot/mujoco_lerobot_train
|
| 82 |
```
|
| 83 |
|
| 84 |
## 运行
|
| 85 |
|
| 86 |
+
先激活环境并进入目录:
|
| 87 |
|
| 88 |
```bash
|
| 89 |
conda activate lerobot
|
| 90 |
+
cd /Users/liuchu/codes/robot/mujoco_lerobot_train
|
| 91 |
```
|
| 92 |
|
| 93 |
Collect dataset:
|
| 94 |
|
| 95 |
```bash
|
| 96 |
+
python collect_dataset.py
|
| 97 |
```
|
| 98 |
|
| 99 |
Visualize dataset:
|
| 100 |
|
| 101 |
```bash
|
| 102 |
+
python viz_dataset.py
|
| 103 |
```
|
| 104 |
|
| 105 |
Train with the Python entry:
|
| 106 |
|
| 107 |
```bash
|
| 108 |
+
python train_policy.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
```
|
| 110 |
|
| 111 |
Closed-loop MuJoCo evaluation:
|
| 112 |
|
| 113 |
```bash
|
| 114 |
+
python eval_policy.py
|
| 115 |
```
|
| 116 |
|
| 117 |
闭环 MuJoCo 评估:
|
| 118 |
|
| 119 |
```bash
|
| 120 |
+
python eval_policy.py
|
| 121 |
```
|
| 122 |
|
| 123 |
## Config
|
|
|
|
| 159 |
Then upload this folder:
|
| 160 |
|
| 161 |
```bash
|
| 162 |
+
bash ./upload_to_hf.sh <user_or_org>/<repo_name>
|
| 163 |
```
|
| 164 |
|
| 165 |
Private repo:
|
| 166 |
|
| 167 |
```bash
|
| 168 |
+
HF_PRIVATE=1 bash ./upload_to_hf.sh <user_or_org>/<repo_name>
|
| 169 |
```
|
| 170 |
|
| 171 |
Dataset repo instead of model repo:
|
| 172 |
|
| 173 |
```bash
|
| 174 |
+
HF_REPO_TYPE=dataset bash ./upload_to_hf.sh <user_or_org>/<repo_name>
|
| 175 |
```
|
| 176 |
|
| 177 |
Ignored during upload:
|
common.py
CHANGED
|
@@ -5,37 +5,10 @@ import os
|
|
| 5 |
import shlex
|
| 6 |
import shutil
|
| 7 |
import subprocess
|
| 8 |
-
import sys
|
| 9 |
import time
|
| 10 |
from dataclasses import dataclass
|
| 11 |
from pathlib import Path
|
| 12 |
|
| 13 |
-
|
| 14 |
-
def ensure_lerobot_importable() -> None:
|
| 15 |
-
try:
|
| 16 |
-
import lerobot # noqa: F401
|
| 17 |
-
|
| 18 |
-
return
|
| 19 |
-
except ModuleNotFoundError:
|
| 20 |
-
pass
|
| 21 |
-
|
| 22 |
-
candidates = [
|
| 23 |
-
Path.home() / "lerobot" / "src",
|
| 24 |
-
Path.home() / "codes" / "lerobot" / "src",
|
| 25 |
-
]
|
| 26 |
-
if "LEROBOT_SRC" in os.environ:
|
| 27 |
-
candidates.insert(0, Path(os.environ["LEROBOT_SRC"]).expanduser())
|
| 28 |
-
|
| 29 |
-
for candidate in candidates:
|
| 30 |
-
if candidate.exists():
|
| 31 |
-
sys.path.insert(0, str(candidate))
|
| 32 |
-
return
|
| 33 |
-
|
| 34 |
-
raise ModuleNotFoundError("Could not import `lerobot`. Install it or set `LEROBOT_SRC`.")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
ensure_lerobot_importable()
|
| 38 |
-
|
| 39 |
import mujoco
|
| 40 |
import numpy as np
|
| 41 |
import torch
|
|
@@ -188,19 +161,7 @@ def load_config(config_path: str | Path | None = None) -> AppConfig:
|
|
| 188 |
|
| 189 |
|
| 190 |
def lerobot_env() -> dict[str, str]:
|
| 191 |
-
|
| 192 |
-
candidates = [
|
| 193 |
-
Path.home() / "lerobot" / "src",
|
| 194 |
-
Path.home() / "codes" / "lerobot" / "src",
|
| 195 |
-
]
|
| 196 |
-
if "LEROBOT_SRC" in env:
|
| 197 |
-
candidates.insert(0, Path(env["LEROBOT_SRC"]).expanduser())
|
| 198 |
-
for candidate in candidates:
|
| 199 |
-
if candidate.exists():
|
| 200 |
-
current = env.get("PYTHONPATH")
|
| 201 |
-
env["PYTHONPATH"] = f"{candidate}:{current}" if current else str(candidate)
|
| 202 |
-
break
|
| 203 |
-
return env
|
| 204 |
|
| 205 |
|
| 206 |
def maybe_reexec_with_mjpython(show_viewer: bool, env_key: str) -> None:
|
|
@@ -521,9 +482,7 @@ def run_subprocess(cmd: list[str]) -> None:
|
|
| 521 |
|
| 522 |
def viz_dataset(cfg: AppConfig) -> None:
|
| 523 |
cmd = [
|
| 524 |
-
|
| 525 |
-
"-m",
|
| 526 |
-
"lerobot.scripts.lerobot_dataset_viz",
|
| 527 |
"--repo-id",
|
| 528 |
cfg.dataset.repo_id,
|
| 529 |
"--root",
|
|
|
|
| 5 |
import shlex
|
| 6 |
import shutil
|
| 7 |
import subprocess
|
|
|
|
| 8 |
import time
|
| 9 |
from dataclasses import dataclass
|
| 10 |
from pathlib import Path
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
import mujoco
|
| 13 |
import numpy as np
|
| 14 |
import torch
|
|
|
|
| 161 |
|
| 162 |
|
| 163 |
def lerobot_env() -> dict[str, str]:
|
| 164 |
+
return os.environ.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
def maybe_reexec_with_mjpython(show_viewer: bool, env_key: str) -> None:
|
|
|
|
| 482 |
|
| 483 |
def viz_dataset(cfg: AppConfig) -> None:
|
| 484 |
cmd = [
|
| 485 |
+
"lerobot-dataset-viz",
|
|
|
|
|
|
|
| 486 |
"--repo-id",
|
| 487 |
cfg.dataset.repo_id,
|
| 488 |
"--root",
|
upload_to_hf.sh
CHANGED
|
@@ -9,8 +9,8 @@ PRIVATE_FLAG="${HF_PRIVATE:-0}"
|
|
| 9 |
CLI_BIN="${HF_CLI_BIN:-huggingface-cli}"
|
| 10 |
|
| 11 |
if [[ -z "$REPO_ID" ]]; then
|
| 12 |
-
echo "usage: bash
|
| 13 |
-
echo "example: bash
|
| 14 |
exit 1
|
| 15 |
fi
|
| 16 |
|
|
|
|
| 9 |
CLI_BIN="${HF_CLI_BIN:-huggingface-cli}"
|
| 10 |
|
| 11 |
if [[ -z "$REPO_ID" ]]; then
|
| 12 |
+
echo "usage: bash ./upload_to_hf.sh <repo_id>"
|
| 13 |
+
echo "example: bash ./upload_to_hf.sh lcccluck/mujoco-lerobot-train"
|
| 14 |
exit 1
|
| 15 |
fi
|
| 16 |
|