GWAM_Data / scripts /README.md
ChangChrisLiu's picture
Add reusable RGB graph alignment verifier
4abeb6f verified
|
Raw
History Blame Contribute Delete
2.73 kB

Scripts

Utilities for direct online final-graph runs from an HF checkout.

setup_realtime_final_graph_env.sh   # create/update a conda env with RoboCasa, torch, SAM2 code, and OpenAI CLIP
verify_realtime_final_graph.py      # run one live RoboCasa OpenDrawer final-graph smoke and assert D_node=342
verify_rgb_graph_alignment.py       # verify graph/view masks/RGB alignment and saved rgb_manifest round-trip

The verifier uses bundled model checkpoints by default:

models/sam2/checkpoints/sam2.1_hiera_base_plus.pt
models/clip/ViT-B-32.pt

RoboCasa simulator assets are not redistributed here; follow upstream RoboCasa setup for assets.

Multi-view RGB / graph alignment contract

For joint training, evaluation, and real-time inference, the model-facing online call is:

snapshot = extractor.extract_final_graph(visual_backend=visual_backend)
graph = snapshot["gnn_graph"]          # x [N_real,342], edge_attr [E,8]
rgb_frames = snapshot["rgb_frames"]             # dict: view_id -> uint8[256,256,3]
rgb_frame_cameras = snapshot["rgb_frame_cameras"]  # ordered camera names for those view ids

All fields in one snapshot are produced from the same current simulator state before the policy/env step advances:

current qpos/qvel/contact state
+ current segmentation renders from the ordered camera list
+ current RGB renders from the same ordered camera list
+ current visible RLE masks indexed by (node slot n, view id v)
+ SAM2 masked pooling on rgb_frames[v] using that same mask
= final graph x [N_real,342]

The ordered multi-view camera contract is:

v=0 robot0_agentview_right
v=1 robot0_agentview_left
v=2 robot0_eye_in_hand

Alignment rules for downstream integration:

  • view_visible[n,v], view_centroid[n,v], view_area[n,v], view_bbox[n,v], rle_masks[*]["v"], visual_features_sparse["v"], and rgb_frames[v] use the same view id.
  • visual_features_sparse["n"] uses the original padded node slot id; gnn_graph["slot_ids"] maps active GNN rows back to those padded slots.
  • rgb_frames[v] is an upright uint8[256,256,3] RGB frame rendered with the same vertical flip convention as the segmentation/mask path.
  • save_realtime_graph_snapshot(snapshot, out_dir) writes rgb/view_<v>_<camera>.npy plus rgb_manifest.json, so saved debug/eval snapshots contain graph data first and aligned RGB images alongside it.

Alignment gate:

MUJOCO_GL=egl PYOPENGL_PLATFORM=egl python scripts/verify_rgb_graph_alignment.py

This uses a deterministic fake visual backend by default so it checks graph/RGB/mask plumbing without requiring SAM2. Use verify_realtime_final_graph.py --visual-backend sam2 for the real SAM2/CLIP gate.