Files
lerobot-clone/README.md

172 lines
3.7 KiB
Markdown
Raw Normal View History

# LeRobot
## Installation
2024-03-12 10:05:05 +01:00
Create a virtual environment with Python 3.10, e.g. using `conda`:
```
2024-02-28 19:11:29 +01:00
conda create -y -n lerobot python=3.10
conda activate lerobot
```
2024-02-28 19:11:29 +01:00
[Install `poetry`](https://python-poetry.org/docs/#installation) (if you don't have it already)
2024-02-28 10:57:08 +01:00
```
2024-02-29 12:26:35 +01:00
curl -sSL https://install.python-poetry.org | python -
2024-02-28 10:57:08 +01:00
```
2024-02-28 19:11:29 +01:00
Install dependencies
2024-02-28 10:57:08 +01:00
```
2024-02-28 19:11:29 +01:00
poetry install
2024-02-28 10:57:08 +01:00
```
2024-02-28 19:11:29 +01: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 10:57:08 +01:00
```
2024-02-28 19:11:29 +01:00
mkdir ~/tmp
export TMPDIR='~/tmp'
2024-02-28 10:57:08 +01:00
```
2024-03-12 10:05:05 +01:00
To use [Weights and Biases](https://docs.wandb.ai/quickstart) for experiments tracking, log in with
2024-03-11 13:09:46 +01:00
```
wandb login
```
2024-02-22 12:14:12 +00:00
## Usage
### Train
```
python lerobot/scripts/train.py \
2024-02-27 11:44:26 +00:00
hydra.job.name=pusht \
env=pusht
2024-02-22 12:14:12 +00:00
```
### Visualize offline buffer
```
python lerobot/scripts/visualize_dataset.py \
2024-02-27 11:44:26 +00:00
hydra.run.dir=tmp/$(date +"%Y_%m_%d") \
env=pusht
2024-02-22 12:14:12 +00:00
```
### Visualize online buffer / Eval
```
python lerobot/scripts/eval.py \
2024-02-27 11:44:26 +00:00
hydra.run.dir=tmp/$(date +"%Y_%m_%d") \
env=pusht
2024-02-22 12:14:12 +00:00
```
## TODO
If you are not sure how to contribute or want to know the next features we working on, look on this project page: [LeRobot TODO](https://github.com/users/Cadene/projects/1)
Ask [Remi Cadene](re.cadene@gmail.com) for access if needed.
## 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-30 23:30:14 +00:00
## Contribute
2024-02-25 10:52:31 +00:00
**Style**
2024-01-30 23:30:14 +00:00
```
2024-02-29 23:31:32 +00:00
# install if needed
2024-02-29 12:26:35 +01:00
pre-commit install
2024-02-29 23:31:32 +00:00
# apply style and linter checks before git commit
pre-commit run -a
2024-01-30 23:30:14 +00:00
```
2024-02-25 10:52:31 +00:00
2024-03-14 15:24:38 +01:00
**Adding dependencies (temporary)**
Right now, for the CI to work, whenever a new dependency is added it needs to be also added to the cpu env, eg:
```
# Run in this directory, adds the package to the main env with cuda
poetry add some-package
# Adds the same package to the cpu env
cd .github/poetry/cpu && poetry add some-package
```
2024-02-25 10:52:31 +00:00
**Tests**
2024-03-08 16:48:33 +01:00
Install [git lfs](https://git-lfs.com/) to retrieve test artifacts (if you don't have it already).
2024-03-11 13:09:46 +01:00
2024-03-08 16:48:33 +01:00
On Mac:
```
brew install git-lfs
git lfs install
```
On Ubuntu:
```
sudo apt-get install git-lfs
git lfs install
```
Pull artifacts if they're not in [tests/data](tests/data)
```
git lfs pull
```
2024-03-09 15:57:29 +01:00
When adding a new dataset, mock it with
```
python tests/scripts/mock_dataset.py --in-data-dir data/<dataset_id> --out-data-dir tests/data/<dataset_id>
```
Run tests
2024-02-25 10:52:31 +00:00
```
2024-03-08 16:48:33 +01:00
DATA_DIR="tests/data" pytest -sx tests
2024-02-29 12:26:35 +01:00
```
2024-03-11 13:49:08 +01:00
2024-03-15 00:30:11 +00:00
**Datasets**
To add a pytorch rl dataset to the hub, first login and use a token generated from [huggingface settings](https://huggingface.co/settings/tokens) with write access:
```
huggingface-cli login --token $HUGGINGFACE_TOKEN --add-to-git-credential
```
Then you can upload it to the hub with:
```
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli upload --repo-type dataset $HF_USER/$DATASET data/$DATASET
```
For instance, for [cadene/pusht](https://huggingface.co/datasets/cadene/pusht), we used:
```
HF_USER=cadene
DATASET=pusht
```
2024-03-12 10:05:05 +01:00
## Acknowledgment
2024-03-11 13:49:08 +01:00
- Our Diffusion policy and Pusht environment are adapted from [Diffusion Policy](https://diffusion-policy.cs.columbia.edu/)
- Our TDMPC policy and Simxarm environment are adapted from [FOWM](https://www.yunhaifeng.com/FOWM/)
2024-03-11 14:20:05 +01:00
- Our ACT policy and ALOHA environment are adapted from [ALOHA](https://tonyzhaozh.github.io/aloha/)