| """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 |
|
|
| |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) |
| import load_failbench as fb |
|
|
|
|
| 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')}") |
|
|
| |
| if cache_root: |
| target = fb.heatmap_from_projection(cache_root, split, task, tid) |
| print(f"\ncached target heatmap (failure-induced, filtered): {target.shape} sum={target.sum():.1f}") |
| target_live = fb.heatmap_from_contacts(trial) |
| 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() |
|
|