File size: 2,690 Bytes
9cbc687
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""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()