lerobot/examples/2_evaluate_pretrained_polic...

28 lines
1020 B
Python
Raw Normal View History

2024-03-27 00:13:40 +08:00
"""
This scripts demonstrates how to evaluate a pretrained policy from the HuggingFace Hub or from your local
training outputs directory. In the latter case, you might want to run examples/3_train_policy.py first.
"""
from pathlib import Path
from huggingface_hub import snapshot_download
from lerobot.scripts.eval import eval
# Get a pretrained policy from the hub.
pretrained_policy_name = "lerobot/diffusion_pusht"
pretrained_policy_path = Path(snapshot_download(pretrained_policy_name))
2024-03-27 00:13:40 +08:00
# OR uncomment the following to evaluate a policy from the local outputs/train folder.
# pretrained_policy_path = Path("outputs/train/example_pusht_diffusion")
2024-03-27 00:13:40 +08:00
# Override some config parameters to do with evaluation.
overrides = [
2024-04-30 23:08:59 +08:00
"eval.n_episodes=10",
"eval.batch_size=10",
2024-03-27 00:13:40 +08:00
"device=cuda",
]
# Evaluate the policy and save the outputs including metrics and videos.
# TODO(rcadene, alexander-soare): dont call eval, but add the minimal code snippet to rollout
eval(pretrained_policy_path=pretrained_policy_path)