2024-01-29 20:49:30 +08:00
|
|
|
# LeRobot
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2024-02-29 02:11:29 +08:00
|
|
|
Create a virtual environment with python 3.10, e.g. using `conda`:
|
2024-01-29 20:49:30 +08:00
|
|
|
```
|
2024-02-29 02:11:29 +08:00
|
|
|
conda create -y -n lerobot python=3.10
|
2024-01-29 20:49:30 +08:00
|
|
|
conda activate lerobot
|
|
|
|
```
|
|
|
|
|
2024-02-29 02:11:29 +08:00
|
|
|
[Install `poetry`](https://python-poetry.org/docs/#installation) (if you don't have it already)
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
2024-02-29 02:11:29 +08:00
|
|
|
curl -sSL https://install.python-poetry.org | python3 -
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
|
|
|
|
2024-02-29 02:11:29 +08:00
|
|
|
Install dependencies
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
2024-02-29 02:11:29 +08:00
|
|
|
poetry install
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
|
|
|
|
2024-02-29 02:11:29 +08:00
|
|
|
If you encounter a disk space error, try to change your tmp dir to a location where you have enough disk space, e.g.
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
2024-02-29 02:11:29 +08:00
|
|
|
mkdir ~/tmp
|
|
|
|
export TMPDIR='~/tmp'
|
2024-02-28 17:57:08 +08:00
|
|
|
```
|
|
|
|
|
2024-02-29 02:11:29 +08:00
|
|
|
Install `diffusion_policy` #HACK
|
2024-01-31 07:30:14 +08:00
|
|
|
```
|
2024-02-29 02:11:29 +08:00
|
|
|
git clone https://github.com/real-stanford/diffusion_policy
|
|
|
|
cp -r diffusion_policy/diffusion_policy $(poetry env info -p)/lib/python3.10/site-packages/
|
2024-01-31 07:30:14 +08:00
|
|
|
```
|
|
|
|
|
2024-02-22 20:14:12 +08:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
### Train
|
|
|
|
|
|
|
|
```
|
|
|
|
python lerobot/scripts/train.py \
|
2024-02-27 19:44:26 +08:00
|
|
|
hydra.job.name=pusht \
|
|
|
|
env=pusht
|
2024-02-22 20:14:12 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### Visualize offline buffer
|
|
|
|
|
|
|
|
```
|
|
|
|
python lerobot/scripts/visualize_dataset.py \
|
2024-02-27 19:44:26 +08:00
|
|
|
hydra.run.dir=tmp/$(date +"%Y_%m_%d") \
|
|
|
|
env=pusht
|
2024-02-22 20:14:12 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### Visualize online buffer / Eval
|
|
|
|
|
|
|
|
```
|
|
|
|
python lerobot/scripts/eval.py \
|
2024-02-27 19:44:26 +08:00
|
|
|
hydra.run.dir=tmp/$(date +"%Y_%m_%d") \
|
|
|
|
env=pusht
|
2024-02-22 20:14:12 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2024-02-16 23:13:24 +08:00
|
|
|
## TODO
|
|
|
|
|
2024-02-16 23:14:59 +08:00
|
|
|
- [x] priority update doesnt match FOWM or original paper
|
|
|
|
- [x] self.step=100000 should be updated at every step to adjust to horizon of planner
|
2024-02-16 23:13:24 +08:00
|
|
|
- [ ] prefetch replay buffer to speedup training
|
|
|
|
- [ ] parallelize env to speedup eval
|
2024-02-17 00:27:54 +08:00
|
|
|
- [ ] clean checkpointing / loading
|
|
|
|
- [ ] clean logging
|
|
|
|
- [ ] clean config
|
|
|
|
- [ ] clean hyperparameter tuning
|
|
|
|
- [ ] add pusht
|
|
|
|
- [ ] add aloha
|
|
|
|
- [ ] add act
|
|
|
|
- [ ] add diffusion
|
|
|
|
- [ ] add aloha 2
|
2024-02-10 23:46:24 +08:00
|
|
|
|
2024-02-25 02:18:39 +08:00
|
|
|
## Profile
|
|
|
|
|
|
|
|
**Example**
|
|
|
|
```python
|
|
|
|
from torch.profiler import profile, record_function, ProfilerActivity
|
|
|
|
|
|
|
|
def trace_handler(prof):
|
|
|
|
prof.export_chrome_trace(f"tmp/trace_schedule_{prof.step_num}.json")
|
|
|
|
|
|
|
|
with profile(
|
|
|
|
activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA],
|
|
|
|
schedule=torch.profiler.schedule(
|
|
|
|
wait=2,
|
|
|
|
warmup=2,
|
|
|
|
active=3,
|
|
|
|
),
|
|
|
|
on_trace_ready=trace_handler
|
|
|
|
) as prof:
|
|
|
|
with record_function("eval_policy"):
|
|
|
|
for i in range(num_episodes):
|
|
|
|
prof.step()
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
python lerobot/scripts/eval.py \
|
|
|
|
pretrained_model_path=/home/rcadene/code/fowm/logs/xarm_lift/all/default/2/models/final.pt \
|
|
|
|
eval_episodes=7
|
|
|
|
```
|
|
|
|
|
2024-01-31 07:30:14 +08:00
|
|
|
## Contribute
|
|
|
|
|
2024-02-25 18:52:31 +08:00
|
|
|
**Style**
|
2024-01-31 07:30:14 +08:00
|
|
|
```
|
2024-02-25 19:09:47 +08:00
|
|
|
isort lerobot && isort tests && black lerobot && black tests
|
|
|
|
pylint lerobot && pylint tests # not enforce for now
|
2024-01-31 07:30:14 +08:00
|
|
|
```
|
2024-02-25 18:52:31 +08:00
|
|
|
|
|
|
|
**Tests**
|
|
|
|
```
|
|
|
|
pytest -sx tests
|
|
|
|
```
|