Datasets:
Download examples/quickstart.py from aaronngx/failbench-robocasa-v2: direct link, hf CLI and curl.
- Browser
- Download file 2.69 kB
-
https://huggingface.co/datasets/aaronngx/failbench-robocasa-v2/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://datasets/aaronngx/failbench-robocasa-v2/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/datasets/aaronngx/failbench-robocasa-v2/resolve/main/examples/quickstart.py
2.69 kB
| """FailBench v2 quickstart — download a repo, load a trial, rebuild its contact target. | |
| pip install -r requirements.txt | |
| python -c "from huggingface_hub import snapshot_download as s; \ | |
| s('aaronngx/failbench-robocasa-v2', repo_type='dataset', local_dir='failbench-robocasa-v2')" | |
| python examples/quickstart.py --data_root failbench-robocasa-v2 | |
| Everything here uses only the standalone `load_failbench.py` (pure h5py+numpy+scipy) — no | |
| FailBench package, no MuJoCo. For training, see the `unet`/`mlp` command in the README. | |
| """ | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| # make load_failbench importable whether you run from repo root or examples/ | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| import load_failbench as fb # noqa: E402 | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--data_root", required=True, help="downloaded repo root (contains v2/)") | |
| ap.add_argument("--cache_root", default=None, | |
| help="optional target_cache/ dir (defaults to <data_root>/target_cache)") | |
| args = ap.parse_args() | |
| cache_root = args.cache_root | |
| if cache_root is None and (Path(args.data_root) / "target_cache").exists(): | |
| cache_root = str(Path(args.data_root) / "target_cache") | |
| df = fb.load_manifest(args.data_root) | |
| print(f"{len(df)} trials, {df['task'].nunique()} tasks, splits={sorted(df['split'].unique())}") | |
| row = (df[df["n_contacts"] > 0] if "n_contacts" in df else df).iloc[0] | |
| split, task, tid = row["split"], row["task"], row["trial_id"] | |
| trial = fb.read_trial(fb.resolve_h5(args.data_root, split, task), tid) | |
| print(f"\ntrial {split}/{task}/{tid}") | |
| print(f" pre_rgb {trial['pre_rgb'].shape} (H,W,3 uint8)") | |
| print(f" window_agentview {trial['window_agentview_rgb'].shape} (T=8,H,W,3)") | |
| print(f" contacts {trial['contact_positions'].shape} world-frame xyz") | |
| print(f" failure {trial.get('failure_mode')} @ progress {trial.get('traj_progress')}") | |
| # contact-prediction TARGET: (240,320) heatmap, the model's supervision signal | |
| if cache_root: | |
| target = fb.heatmap_from_projection(cache_root, split, task, tid) # filtered (training target) | |
| print(f"\ncached target heatmap (failure-induced, filtered): {target.shape} sum={target.sum():.1f}") | |
| target_live = fb.heatmap_from_contacts(trial) # rebuilt from raw contacts, no cache/sim | |
| print(f"on-the-fly heatmap (all contacts): {target_live.shape} sum={target_live.sum():.1f}") | |
| print("\nDone. `target` (240,320) is what the contact-prediction model regresses.") | |
| if __name__ == "__main__": | |
| main() | |