Add pretrained notebook
This commit is contained in:
31
examples/notebook_utils.py
Normal file
31
examples/notebook_utils.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from pprint import pprint
|
||||
|
||||
from hydra import compose, initialize
|
||||
from hydra.core.global_hydra import GlobalHydra
|
||||
from omegaconf import OmegaConf
|
||||
from omegaconf.dictconfig import DictConfig
|
||||
|
||||
CONFIG_DIR = "../lerobot/configs"
|
||||
DEFAULT_CONFIG = "default"
|
||||
|
||||
|
||||
def config_notebook(
|
||||
policy: str = "diffusion",
|
||||
env: str = "pusht",
|
||||
device: str = "cpu",
|
||||
config_name=DEFAULT_CONFIG,
|
||||
config_path=CONFIG_DIR,
|
||||
print_config: bool = False,
|
||||
) -> DictConfig:
|
||||
GlobalHydra.instance().clear()
|
||||
initialize(config_path=config_path)
|
||||
overrides = [
|
||||
f"env={env}",
|
||||
f"policy={policy}",
|
||||
f"device={device}",
|
||||
]
|
||||
cfg = compose(config_name=config_name, overrides=overrides)
|
||||
if print_config:
|
||||
pprint(OmegaConf.to_container(cfg))
|
||||
|
||||
return cfg
|
||||
56
examples/pretrained.ipynb
Normal file
56
examples/pretrained.ipynb
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"from IPython.display import Video\n",
|
||||
"\n",
|
||||
"from examples.notebook_utils import config_notebook\n",
|
||||
"from lerobot.scripts.eval import eval\n",
|
||||
"\n",
|
||||
"OUT_DIR = Path(\"./outputs\")\n",
|
||||
"POLICY = \"act\"\n",
|
||||
"ENV = \"aloha\"\n",
|
||||
"\n",
|
||||
"# setup config\n",
|
||||
"cfg = config_notebook(policy=POLICY, env=ENV, device=\"cpu\", print_config=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"eval(cfg, out_dir=OUT_DIR)\n",
|
||||
"Video(OUT_DIR / \"eval\" / \"eval_episode_0.mp4\", embed=True)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "lerobot",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.13"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user