# ARKitScenes → 3D-Belief finetuning End-to-end procedure for wiring **ARKitScenes** (Apple iPad LiDAR room captures) into 3D-Belief training via the CUT3R adapter, plus the single-scene overfit used to validate the dataloader before multi-scene training. This mirrors the WildRGBD / ScanNet++ ports — see [`WILDRGBD.md`](WILDRGBD.md) and the `3d-belief-dataloader` skill for the shared invariants. Only the ARKitScenes-specific decisions are spelled out here. TL;DR of what was added: | file | change | |---|---| | `splat_belief/data_io/cut3r_adapter.py` | `_make_arkitscenes_short()` helper + `arkitscenes` branch now uses it | | `splat_belief/data_io/__init__.py` | registered `arkitscenes_cut3r` in `get_path` + the adapter tuple | | `splat_belief/config/dataset/arkitscenes_cut3r.yaml` | new Hydra dataset config (room-scale near/far, metric depth) | | `scripts/data_prep/verify_arkitscenes_pose_convention.py` | convention + schema + drift verifier | | `scripts/training/finetune_arkitscenes_overfit.sh` | single-scene overfit launcher (DFoT init, depth mask on) | --- ## 1. Preprocessing (CUT3R) ARKitScenes uses the **two-step** CUT3R pipeline (`docs/preprocess.md`), identical in shape to ScanNet: `preprocess_*` writes per-frame RGB/depth + `scene_metadata.npz` (with DUSt3R `pairs`); `generate_set_*` then writes `new_scene_metadata.npz` (with the `image_collection` / `video_collection` that the `ARKitScenes_Multi` loader actually reads at train time). ### 1a. Inputs - **Raw data**: `data/ARKitScenes/raw/{Training,Validation}//` with `vga_wide/` (RGB), `lowres_depth/` (uint16 mm LiDAR depth), `vga_wide_intrinsics/` (`*.pincam`), and `lowres_wide.traj` (per-frame device pose, angle-axis + t). - **Precomputed pairs** (required by `preprocess_arkitscenes.py`): DUSt3R's [`arkitscenes_pairs.zip`](https://download.europe.naverlabs.com/ComputerVision/DUSt3R/arkitscenes_pairs.zip), unzipped to `data/ARKitScenes/arkitscenes_pairs/{Training,Test}/`. The script reads `scene_list.json` + per-scene `selected_pairs.npz`; **without it the preprocessor cannot run** (it drives which frames are selected/exported). ### 1b. Commands (run from `third_party/CUT3R/datasets_preprocess`) Use the `3d-belief-release` conda env's python for preprocessing — it has `numpy<2` + `numpy-quaternion` (the `3d-belief` training env has numpy 2.x where `quaternion` is ABI-broken; that's fine because the **dataloader** path never imports quaternion). Use the **absolute** interpreter path; `conda run -n ` is broken on this host (it silently resolves to the colmap-cuda env's py3.14). ```bash PY=/home/ubuntu/tianmin-neurips/miniconda3/envs/3d-belief-release/bin/python DATA=/home/ubuntu/tianmin-neurips/zwen19/data/ARKitScenes # Step 1 — convert RGB/depth + interpolate poses to selected timestamps. $PY preprocess_arkitscenes.py \ --arkitscenes_dir "$DATA/raw" \ --precomputed_pairs "$DATA/arkitscenes_pairs" \ --output_dir "$DATA/processed_arkitscenes" # Step 2 — build image_collection / video_collection metadata. $PY generate_set_arkitscenes.py \ --root "$DATA/processed_arkitscenes" \ --splits Training Test --max_interval 5.0 --num_workers 8 ``` Output layout (per scene): `processed_arkitscenes/Training//{vga_wide/*.jpg, lowres_depth/*.png, scene_metadata.npz, new_scene_metadata.npz}` plus a top-level `all_metadata.npz` + `scene_list.json` per split. ### 1c. Subset preprocessing (this run) The full ARKitScenes is still downloading, so only a **5-scene subset** was processed for the overfit smoke. The official `preprocess_arkitscenes.py` hardcodes `subdirs=["Test","Training"]` and crashes on an empty split (`np.concatenate([])`), and iterates the *entire* pairs `scene_list.json`. To process just a subset without touching the original script: 1. Build `arkitscenes_pairs_subset/` with a filtered `Training/scene_list.json` (chosen scenes), symlinked `Training//selected_pairs.npz`, and an empty `Test/scene_list.json` (`[]`). 2. Run a `/tmp` copy of `preprocess_arkitscenes.py` patched to `subdirs=["Training"]` (avoids the empty-Test crash; the original CUT3R script is left intact). 3. Run `generate_set_arkitscenes.py --splits Training` on the output. Valid processed scenes: **`40958756`** (162 selected frames — overfit target), `41045408`, `41098145`. (Re-run on the full pairs `scene_list` once the download completes; no code changes needed.) --- ## 2. Dataloader wiring ### 2a. `_make_arkitscenes_short()` — the ARKitScenes-specific subclass The raw CUT3R `ARKitScenes_Multi` is **not** directly usable for 3D-Belief; the helper returns a subclass fixing three things (full rationale in the docstring): 1. **`_highres` crash.** `_load_data` does `np.setdiff1d(scenes, os.listdir(ROOT + "_highres"/split))` to drop scenes that also exist in the high-res variant. We only process the regular split, so the subclass stubs empty `_highres/{Training,Validation}` dirs before `_load_data` runs → the setdiff is a no-op. 2. **50/50 shuffled sampling.** `_get_views` flips `rng.choice([True,False])` between a temporal-video sequence and a *permuted* DUSt3R-pairs group. The pairs branch is wide-baseline + non-temporal, which breaks the `[ctxt, intm…, trgt]` time ordering 3D-Belief's intermediate loss requires. A tiny `_ForceVideoRng` proxy makes the branch selector always return the video branch, forwarding every other rng call unchanged. 3. **Pose drift too wide.** Default `max_interval=8` + `video_prob=0.8` give multi-frame gaps. The subclass forces `video_prob=1.0` (always time-ordered) and tightens `max_interval=2`, matching `_make_scannet_short`. ### 2b. Hydra config (`arkitscenes_cut3r.yaml`) Room-scale handheld capture, so it differs from object-centric WildRGBD: | key | value | why | |---|---|---| | `cut3r_dataset_class` | `arkitscenes` | routes to `_make_arkitscenes_short` | | `viz_type` | `interpolation` | ctxt/trgt are close after short-window sampling → linear interp stays in seen views (WildRGBD needed `spherical` because object-centric) | | `near` / `far` | **0.1 / 10.0** | room-scale indoor; covers full room while keeping splat precision tighter than the 20 m RE10K/ScanNet default | | `depth_loss_weight` | 1.0 | per-frame **metric** LiDAR depth on every pixel | | `depth_smooth_loss_weight` | 0.1 | canonical (regularizes predicted depth) | | `intermediate_weight` | 5.0 | canonical (train.sh / train_re10k.sh) | | `vggt_alignment_loss_weight` | 2.0 | canonical | | `camera.fx`/`fy` | 1.16 | **measured** fx_norm after the square center-crop (HFOV ≈ 47°); cx/cy ≈ 0.5 confirms centered crop. Nominal fallback only — per-sample K from the dataset dict takes precedence. | --- ## 3. Camera convention — VERIFIED OpenCV c2w (no flip) This was the make-or-break check. ARKit raw poses are OpenGL-ish, and CUT3R's preprocessor applies a non-trivial `pose_cam_to_world @ rotated_to_cam` (an in-plane sky-direction rotation), so the output convention was **not assumed** — it was tested on real geometry by `scripts/data_prep/verify_arkitscenes_pose_convention.py`. **Test 1 — camera +Y world axis (Z-up world).** Mean camera +Y → world `(-0.08, -0.12, -0.99)` = dominant **−Z** across all views ⇒ camera-Y points down ⇒ OpenCV (y-down). (OpenGL y-up would give +Z.) **Test 2 — multi-view point-cloud consistency** (the definitive test). Backproject two **adjacent, high-overlap** frames into the world under OpenCV (c2w as-is) vs OpenGL (`c2w @ diag(1,-1,-1,1)`) and measure cross-frame overlap: | frame pair | OpenCV as-is | OpenGL flip | |---|---|---| | (0,1), baseline 2.9 cm | **median 0.011 m · 94% < 5 cm** | 0.016 m · 74% | | (0,2), baseline 6.3 cm | **0.016 m · 93%** | 0.026 m · 62% | | (10,11), rotated | **0.008 m · 94%** | 0.047 m · 53% | OpenCV wins every pair, and the margin **grows with inter-frame rotation** (the (10,11) pair: 94% vs 53%) — conclusive. (Comparing ctxt vs trgt directly is unreliable: they barely overlap, which made an earlier 128-res ctxt/trgt test ambiguous. Always use adjacent frames for this check.) **Conclusion: CUT3R-preprocessed ARKitScenes `camera_pose` is c2w OpenCV.** The `Cut3rAdapter` consumes it unchanged — **no `diag(1,-1,-1,1)` flip** (unlike SPOC's Habitat poses). Adapter schema checks also pass: `ctxt_c2w[0]==identity`, RGB in `[-1,1]`, depth 100% valid, normalized `cx≈cy≈0.5`. **Pose drift** (40 samples, `max_interval=2`): mean translation **0.14 m**, mean rotation **23°** — comfortably inside SPOC's bounds (1.0 m / 45°). `max_interval=2` is a good default; raise it only if the full dataset's selected frames turn out to be more densely spaced in time. --- ## 4. Finetuning / overfit **Init: DFoT weights**, exactly as train.sh / train_re10k.sh / the WildRGBD overfit — `checkpoint_path=checkpoints/DFoT_RE10K.ckpt` (diffusion init, full model) + `model.encoder.encoder_ckpt=checkpoints/re10k.ckpt` (pixelsplat encoder). `load_enc=true`, `load_optimizer=false`. The ~514 missing / 84 unexpected keys on load are **expected** (DFoT init has a different head than the re10k encoder). **Env: use the `3d-belief` conda env (torch 2.11), NOT `3d-belief-release`** — the release env's `diff_gaussian_rasterization/_C.so` is stale (`undefined symbol …decref_pyobject`). The `3d-belief` env has a working rasterizer build. **Depth mask: ENABLED** (the SPOC-style setup the user asked for): `use_depth_supervision=true`, `model.encoder.use_depth_mask=true`. The adapter's `(d>0)&(d5% = collapsed gaussians), and `rendered_10.png` (middle of the sweep) shows a coherent room (window+blinds, furniture), not black. This is the definitive confirmation the dataloader + OpenCV convention are correct — a wrong pose convention or pose-drift bug would empty the middle frames and stall `rgb_loss` above 0.05. Verdict: **a single ARKitScenes scene overfits**, so 3D-Belief can be trained on it. Scale to multi-scene once the full dataset finishes downloading (re-run §1 preprocessing on the full pairs `scene_list`, drop `overfit_to_index`, restore `warmup_period=10000`). --- ## 5. Gotchas (this host / dataset) - **`conda run -n ` is broken here** — silently resolves to the colmap-cuda env (py3.14). Always use absolute interpreter paths (`.../envs//bin/python`). - **Two different envs**: preprocessing → `3d-belief-release` (numpy<2 + quaternion); training → `3d-belief` (torch 2.11, working rasterizer). - **Precomputed pairs are mandatory** for `preprocess_arkitscenes.py`; it won't run without DUSt3R's `arkitscenes_pairs`. - **`generate_set` is not optional** — the loader reads `new_scene_metadata.npz` (image_collection), which only step 2 writes. Step 1 alone → loader finds no groups. - Don't lower `video_prob` back below 1.0 or widen `max_interval` past ~2 for handheld capture — both reintroduce the wide-baseline / non-temporal sampling that empties the gaussian middles. - See [`scripts/data_prep/verify_arkitscenes_pose_convention.py`] — re-run the convention check before any new ARKitScenes training; trusting the upstream c2w without verification is the #1 way to get silent garbage.