Instructions to use tmhoanggg/so101-stack-cup-v3-pi05 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use tmhoanggg/so101-stack-cup-v3-pi05 with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download code/infer_check.py from tmhoanggg/so101-stack-cup-v3-pi05: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/tmhoanggg/so101-stack-cup-v3-pi05/resolve/main/code/infer_check.py
- Command line
-
hf download hf://tmhoanggg/so101-stack-cup-v3-pi05/code/infer_check.py
-
curl -L -o infer_check.py https://huggingface.co/tmhoanggg/so101-stack-cup-v3-pi05/resolve/main/code/infer_check.py
1.79 kB
| """Load a trained pi0.5 checkpoint as the robot PC will and run it on recorded frames: | |
| peak GPU memory, time per action chunk, and error vs the recorded actions (first step of each chunk). | |
| PI05_ENCODER=<arm or empty> python infer_check.py <checkpoint/pretrained_model> [episode=0] [dataset]""" | |
| import os, sys, time, torch, numpy as np | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| if os.environ.get("PI05_ENCODER"): | |
| import encoder_swap | |
| encoder_swap.apply(os.environ["PI05_ENCODER"]) | |
| if os.environ.get("PI05_AUX"): # encoder added through the side branch (aux_inject.py) | |
| import aux_inject | |
| aux_inject.apply(os.environ["PI05_AUX"]) | |
| from lerobot.policies.pi05.modeling_pi05 import PI05Policy | |
| from lerobot.policies.factory import make_pre_post_processors | |
| from lerobot.datasets.lerobot_dataset import LeRobotDataset | |
| ck, ep = sys.argv[1], int(sys.argv[2]) if len(sys.argv) > 2 else 0 | |
| pol = PI05Policy.from_pretrained(ck).to("cuda").eval() | |
| pre, post = make_pre_post_processors(pol.config, pretrained_path=ck) | |
| ds = LeRobotDataset(sys.argv[3] if len(sys.argv) > 3 else "tmhoanggg/so101-stack-cup-v3", episodes=[ep]) | |
| T, err = [], [] | |
| for i in range(0, len(ds), 50): | |
| s = ds[i] | |
| obs = {k: v.unsqueeze(0) for k, v in s.items() if k.startswith("observation.")} | |
| obs["task"] = [s["task"]] | |
| torch.cuda.synchronize(); t = time.perf_counter() | |
| with torch.no_grad(): | |
| a = post(pol.predict_action_chunk(pre(obs))) | |
| torch.cuda.synchronize(); T.append(time.perf_counter() - t) | |
| err.append((a[0, 0].float().cpu() - s["action"]).abs().mean().item()) | |
| print(f"peak VRAM {torch.cuda.max_memory_allocated()/2**30:.2f} GiB | {1000*np.mean(T[1:]):.0f} ms/chunk " | |
| f"| first-action error vs recorded {np.mean(err):.2f} deg over {len(err)} chunks") | |