Upload REPRODUCE.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101# Reproduce / Train MapTokenGS β agent guideSelf-contained instructions to go from the two HuggingFace repos to a trained model.Two repos make up the release (split for licensing β Waymo cannot be public):| repo | visibility | holds ||---|---|---|| `ChenmingWu/mapgs-maptokengs` | public | **all code** + Argoverse-2 data (`data/av2_shard_*.tar`) + checkpoints (`runs/*.safetensors`) + this guide || `ChenmingWu/mapgs-waymo` | private | Waymo data only (`data/waymo_shard_*.tar`) |You need **both** for full Waymo+AV2 training; AV2-only training works from the public repo alone.---## Step 1 β Download both repos```bashpip install -U "huggingface_hub[cli]"huggingface-cli login # needed for the PRIVATE waymo repo# code + AV2 + checkpoints (public)huggingface-cli download ChenmingWu/mapgs-maptokengs --repo-type model --local-dir mapgs-maptokengs# Waymo data (private β requires your token with read access)huggingface-cli download ChenmingWu/mapgs-waymo --repo-type model --local-dir mapgs-waymo```## Step 2 β Reconstruct + MERGE the dataEvery shard tar stores paths as `data/unified/<dataset>/<split>/<clip_id>/β¦`, so untarring allshards **from the same working directory** rebuilds one merged tree. Use the code repo as the root:```bashcd mapgs-maptokengs# AV2 (train+val) -> data/unified/av2/{train,val}/...for f in data/av2_shard_*.tar; do tar -xf "$f"; done# Waymo (train) -> data/unified/waymo/train/... (merges into the SAME data/unified/)for f in ../mapgs-waymo/data/waymo_shard_*.tar; do tar -xf "$f"; donerm -f data/*_shard_*.tar # optional: drop the tarballs# verify the merge (expect ~1822 av2/train, 309 av2/val, ~4590 waymo/train clips):for d in data/unified/av2/train data/unified/av2/val data/unified/waymo/train; doecho "$d: $(ls data/unified/${d#data/unified/} 2>/dev/null | wc -l) clips"; done```Each `<clip_id>/` contains `meta.pt` (poses, intrinsics, HD-map ground field, MAGT anchors,dynamic boxes) + `images/<frame>_<cam>.jpg`. That's the format `UnifiedClipDataset` reads.## Step 3 β EnvironmentPython β₯ 3.11, a CUDA GPU. From the `mapgs-maptokengs` root:```bashpip install torch --index-url https://download.pytorch.org/whl/cu128 # match your CUDApip install gsplat # 3DGS rasterizer (builds against CUDA)pip install git+https://github.com/rahul-goel/fused-ssim.git # TokenGS needs fused_ssimpip install einops safetensors imageio numpy matplotlib transformers huggingface_hubpip install -e _tokengs_repo # the TokenGS backbone package (Apache-2.0)export PYTHONPATH=$PWD # so `mapgs`, `maptokengs`, `scripts` import````transformers` is only for the L_vert mono-depth prior (Depth-Anything-V2-Small, auto-downloadedon first use).## Step 4 β Backbone weights (warm-start)Training **warm-starts from NVIDIA TokenGS `dl3dv_base`** (research-only; NOT redistributed here βget it from the official TokenGS release, github.com/nv-tlabs/TokenGS). Two options:- **From the pretrained backbone:** pass `--ckpt /path/to/dl3dv_base.safetensors`.- **Continue from our finetuned model (no NVIDIA download needed):** our checkpoints in `runs/` arefull weights β pass `--ckpt runs/maptokengs_fixed_best.safetensors` to continue/eval directly.## Step 5 β Train```bashPYTHONPATH=$PWD python scripts/finetune_maptokengs.py \--ckpt /path/to/dl3dv_base.safetensors \--roots data/unified/av2,data/unified/waymo \--val-roots data/unified/av2 \--height 448 --width 768 --n-in 8 \--iters 1200 --eval-every 400 --eval-clips 64 \--out runs/my_run.safetensors```- Evaluates on **held-out scenes** (`av2/val`, disjoint from train) and writes the best held-outcheckpoint to `runs/my_run_best.safetensors`.- **Early-stop ~1000β1200 steps:** held-out PSNR peaks around step 1000 then *overfits* on this6.4k-clip set (it dropped 17.98β15.39 by step 3000) β the `*_best.safetensors` captures the peak,so always use that, not the final.- AV2-only (skip Waymo): `--roots data/unified/av2`.- All losses are on by default: MAGT-anchored map tokens, map-depth + free-space, extrapolationwarp, free-token visibility, PointForward dynamics, L_vert, tempering. Flags: `--lam-md --lam-fs--lam-vis --lam-ext --lam-vert`, ramps `--extrap-ramp --vert-ramp --dyn-ramp`.## Step 6 β Evaluate / visualize / infer```bash# qualitative grid (GT vs predicted novel view vs depth) + out-of-trajectory strip:PYTHONPATH=$PWD python scripts/visualize_maptokengs.py \--ckpt runs/maptokengs_fixed_best.safetensors --s 2.0 # -> runs/viz_nvs.png, viz_oot.png```The training script already prints held-out-SCENE PSNR/SSIM (meanΒ±std) BEFORE/AFTER. Our bestheld-out-scene result: **17.98 Β± 1.4 PSNR / 0.597 SSIM** (`runs/maptokengs_fixed_best.safetensors`).## Notes / gotchas- **Resolution** is capped by stored data: width β€ ~768 (AV2 stored 775w), height β€ ~683 (Waymo).The loader does aspect-preserving cover+crop, so AV2 (portrait) and Waymo (landscape) aren'tdistorted. Going higher needs re-processing from native sensor frames via `scripts/*_to_unified`.- **Eval is held-out SCENES** (av2/val), `s` pinned to `s_max`. Do not eval on train clips(in-sample numbers are inflated).- **Licenses:** Waymo data β do NOT redistribute (regenerate from your own Waymo access via`mapgs/data/convert/waymo_to_unified.py`). AV2 β CC BY-NC-SA 4.0 (attribute Argoverse 2).Checkpoints β derived from NVIDIA TokenGS, research-only / non-commercial.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576# Reproducing MapVGGTFeed-forward driving novel-view synthesis: **VGGT-Omega (1B)** backbone β per-pixel metricdepth β world-space 3D Gaussians (positions from depth + known poses) β `gsplat` render β2D **UNet refine**. MapGS components (HD-map-anchored tokens, scene-graph dynamics, map-awarelosses) are included but were measured neutral on PSNR; the gains are the VGGT backbone +gentle finetuning, plus the UNet refine.> **License: non-commercial research only** β this is a derivative of VGGT-Omega (Meta FAIR> Noncommercial Research License; see `LICENSE`). Do not use commercially. Trained on Waymo> (no data redistribution) + Argoverse 2 (CC BY-NC-SA 4.0).## 1. Environment```bashpip install torch gsplat safetensors imageio transformers huggingface_hub einops# VGGT-Omega code + base weights (obtain from the FAIR-licensed source):git clone https://github.com/facebookresearch/vggt-omega # -> $VGGT_OMEGA_REPO# download vggt_omega_1b_512.pt # -> $MAPVGGT_VGGT_CKPTexport VGGT_OMEGA_REPO=/path/to/vggt-omegaexport MAPVGGT_VGGT_CKPT=/path/to/vggt_omega_1b_512.pt```The base VGGT-Omega weights are **not** redistributed here; the released checkpoints alreadycontain a finetuned copy of them (`model.vggt.*`).## 2. Data (regenerate from your own licensed copies)Every source converts to a unified per-clip format (`meta.pt` + `images/<f>_<v>.jpg`):```bash# Waymo v1.4.3 perception tfrecords -> unified clips (front 3 cams, 20 frames @10fps)python -c "from mapgs.data.convert.waymo_to_unified import convert_waymo; from mapgs.config import load_config; \convert_waymo('/path/to/waymo_tfrecords', 'data/unified/waymo', load_config(), store_longside=640, image_ext='jpg')"# Argoverse 2 sensor logs -> unified clipspython -c "from mapgs.data.convert.av2_to_unified import convert_argoverse2; from mapgs.config import load_config; \convert_argoverse2('/path/to/av2_raw', 'data/unified/av2', load_config())"```Clips are named `train_<segid>_<idx>`; the trainer splits **by segment** (`segid`) to keeptrain/val scene-disjoint (no leakage). `mapgs/data/convert/reconvert_av2_fix.py` adds optionalAV2 lens undistortion.## 3. Train```bash# main model: VGGT backbone finetune + per-pixel head + UNet render-refinePYTHONPATH=$VGGT_OMEGA_REPO python -m scripts.train_mapvggt_refine \--roots data/unified/waymo --iters 4000 --val-segs 40 --eval-every 500 \--out runs/mapvggt_refine.safetensors# backbone-only / +map+dyn ablations:PYTHONPATH=$VGGT_OMEGA_REPO python -m scripts.train_mapvggt_full --finetune-backbone --no-map --no-dyn # basePYTHONPATH=$VGGT_OMEGA_REPO python -m scripts.train_mapvggt_full --finetune-backbone # +map+dyn```Notes: backbone finetuned at lr 1e-5, UNet 3e-4; the held-out PSNR peaks ~step 1000 on the~1157-clip set (data-limited) β keep the best checkpoint. gsplat+bf16 β reproducible at theseed/config level, not bit-exact.## 4. Evaluate a checkpoint```bashPYTHONPATH=$VGGT_OMEGA_REPO python -m scripts.eval_mapvggt \--ckpt checkpoints/mapvggt_refine_best.safetensors --roots data/unified/waymo --val-segs 40# -> held-out-SCENE val (n=40): PSNR 22.67Β±3.76 SSIM 0.689```## 5. Results (held-out-SCENE, segment-disjoint Waymo, 40 scenes, 256Γ448, n_in=8)| checkpoint | PSNR | SSIM ||---|---|---|| `abl_base_best` (VGGT + finetune) | 21.7 | 0.66 || `abl_full_best` (+ map tokens + dynamics) | 21.7 | 0.66 (neutral) || `mapvggt_refine_best` (+ UNet refine) | **22.67** | **0.689** |Honest scope: ~5 dB below published feed-forward driving SOTA (DGGT 27.4 / PointForward 28.5,different protocols). Ablation shows the gain is the backbone + finetune + UNet refine; HD-maptokens, dynamics, resolution, color-fusion, uncertainty-covariance, and a skybox were allmeasured ~neutral (the image-space UNet subsumes them). Binding constraint: training data scale.## Checkpoint format- `mapvggt_refine_best.safetensors`: keys `model.*` (MapVGGT incl. finetuned `model.vggt.*` + `model.head.*`)and `unet.*` (RefineUNet). Load via `scripts/eval_mapvggt.load_mapvggt_refine`.- `abl_base_best` / `abl_full_best`: full-model state (`MapVGGT`, with/without map+dyn heads); load with`MapVGGT(...).load_state_dict(..., strict=False)`.
REPRODUCE.md+60-85