Upload REPRODUCE.md with huggingface_hub
Browse files- REPRODUCE.md +101 -0
REPRODUCE.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Reproduce / Train MapTokenGS — agent guide
|
| 2 |
+
|
| 3 |
+
Self-contained instructions to go from the two HuggingFace repos to a trained model.
|
| 4 |
+
Two repos make up the release (split for licensing — Waymo cannot be public):
|
| 5 |
+
|
| 6 |
+
| repo | visibility | holds |
|
| 7 |
+
|---|---|---|
|
| 8 |
+
| `ChenmingWu/mapgs-maptokengs` | public | **all code** + Argoverse-2 data (`data/av2_shard_*.tar`) + checkpoints (`runs/*.safetensors`) + this guide |
|
| 9 |
+
| `ChenmingWu/mapgs-waymo` | private | Waymo data only (`data/waymo_shard_*.tar`) |
|
| 10 |
+
|
| 11 |
+
You need **both** for full Waymo+AV2 training; AV2-only training works from the public repo alone.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## Step 1 — Download both repos
|
| 16 |
+
```bash
|
| 17 |
+
pip install -U "huggingface_hub[cli]"
|
| 18 |
+
huggingface-cli login # needed for the PRIVATE waymo repo
|
| 19 |
+
|
| 20 |
+
# code + AV2 + checkpoints (public)
|
| 21 |
+
huggingface-cli download ChenmingWu/mapgs-maptokengs --repo-type model --local-dir mapgs-maptokengs
|
| 22 |
+
# Waymo data (private — requires your token with read access)
|
| 23 |
+
huggingface-cli download ChenmingWu/mapgs-waymo --repo-type model --local-dir mapgs-waymo
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## Step 2 — Reconstruct + MERGE the data
|
| 27 |
+
Every shard tar stores paths as `data/unified/<dataset>/<split>/<clip_id>/…`, so untarring all
|
| 28 |
+
shards **from the same working directory** rebuilds one merged tree. Use the code repo as the root:
|
| 29 |
+
```bash
|
| 30 |
+
cd mapgs-maptokengs
|
| 31 |
+
# AV2 (train+val) -> data/unified/av2/{train,val}/...
|
| 32 |
+
for f in data/av2_shard_*.tar; do tar -xf "$f"; done
|
| 33 |
+
# Waymo (train) -> data/unified/waymo/train/... (merges into the SAME data/unified/)
|
| 34 |
+
for f in ../mapgs-waymo/data/waymo_shard_*.tar; do tar -xf "$f"; done
|
| 35 |
+
rm -f data/*_shard_*.tar # optional: drop the tarballs
|
| 36 |
+
|
| 37 |
+
# verify the merge (expect ~1822 av2/train, 309 av2/val, ~4590 waymo/train clips):
|
| 38 |
+
for d in data/unified/av2/train data/unified/av2/val data/unified/waymo/train; do
|
| 39 |
+
echo "$d: $(ls data/unified/${d#data/unified/} 2>/dev/null | wc -l) clips"; done
|
| 40 |
+
```
|
| 41 |
+
Each `<clip_id>/` contains `meta.pt` (poses, intrinsics, HD-map ground field, MAGT anchors,
|
| 42 |
+
dynamic boxes) + `images/<frame>_<cam>.jpg`. That's the format `UnifiedClipDataset` reads.
|
| 43 |
+
|
| 44 |
+
## Step 3 — Environment
|
| 45 |
+
Python ≥ 3.11, a CUDA GPU. From the `mapgs-maptokengs` root:
|
| 46 |
+
```bash
|
| 47 |
+
pip install torch --index-url https://download.pytorch.org/whl/cu128 # match your CUDA
|
| 48 |
+
pip install gsplat # 3DGS rasterizer (builds against CUDA)
|
| 49 |
+
pip install git+https://github.com/rahul-goel/fused-ssim.git # TokenGS needs fused_ssim
|
| 50 |
+
pip install einops safetensors imageio numpy matplotlib transformers huggingface_hub
|
| 51 |
+
pip install -e _tokengs_repo # the TokenGS backbone package (Apache-2.0)
|
| 52 |
+
export PYTHONPATH=$PWD # so `mapgs`, `maptokengs`, `scripts` import
|
| 53 |
+
```
|
| 54 |
+
`transformers` is only for the L_vert mono-depth prior (Depth-Anything-V2-Small, auto-downloaded
|
| 55 |
+
on first use).
|
| 56 |
+
|
| 57 |
+
## Step 4 — Backbone weights (warm-start)
|
| 58 |
+
Training **warm-starts from NVIDIA TokenGS `dl3dv_base`** (research-only; NOT redistributed here —
|
| 59 |
+
get it from the official TokenGS release, github.com/nv-tlabs/TokenGS). Two options:
|
| 60 |
+
- **From the pretrained backbone:** pass `--ckpt /path/to/dl3dv_base.safetensors`.
|
| 61 |
+
- **Continue from our finetuned model (no NVIDIA download needed):** our checkpoints in `runs/` are
|
| 62 |
+
full weights — pass `--ckpt runs/maptokengs_fixed_best.safetensors` to continue/eval directly.
|
| 63 |
+
|
| 64 |
+
## Step 5 — Train
|
| 65 |
+
```bash
|
| 66 |
+
PYTHONPATH=$PWD python scripts/finetune_maptokengs.py \
|
| 67 |
+
--ckpt /path/to/dl3dv_base.safetensors \
|
| 68 |
+
--roots data/unified/av2,data/unified/waymo \
|
| 69 |
+
--val-roots data/unified/av2 \
|
| 70 |
+
--height 448 --width 768 --n-in 8 \
|
| 71 |
+
--iters 1200 --eval-every 400 --eval-clips 64 \
|
| 72 |
+
--out runs/my_run.safetensors
|
| 73 |
+
```
|
| 74 |
+
- Evaluates on **held-out scenes** (`av2/val`, disjoint from train) and writes the best held-out
|
| 75 |
+
checkpoint to `runs/my_run_best.safetensors`.
|
| 76 |
+
- **Early-stop ~1000–1200 steps:** held-out PSNR peaks around step 1000 then *overfits* on this
|
| 77 |
+
6.4k-clip set (it dropped 17.98→15.39 by step 3000) — the `*_best.safetensors` captures the peak,
|
| 78 |
+
so always use that, not the final.
|
| 79 |
+
- AV2-only (skip Waymo): `--roots data/unified/av2`.
|
| 80 |
+
- All losses are on by default: MAGT-anchored map tokens, map-depth + free-space, extrapolation
|
| 81 |
+
warp, free-token visibility, PointForward dynamics, L_vert, tempering. Flags: `--lam-md --lam-fs
|
| 82 |
+
--lam-vis --lam-ext --lam-vert`, ramps `--extrap-ramp --vert-ramp --dyn-ramp`.
|
| 83 |
+
|
| 84 |
+
## Step 6 — Evaluate / visualize / infer
|
| 85 |
+
```bash
|
| 86 |
+
# qualitative grid (GT vs predicted novel view vs depth) + out-of-trajectory strip:
|
| 87 |
+
PYTHONPATH=$PWD python scripts/visualize_maptokengs.py \
|
| 88 |
+
--ckpt runs/maptokengs_fixed_best.safetensors --s 2.0 # -> runs/viz_nvs.png, viz_oot.png
|
| 89 |
+
```
|
| 90 |
+
The training script already prints held-out-SCENE PSNR/SSIM (mean±std) BEFORE/AFTER. Our best
|
| 91 |
+
held-out-scene result: **17.98 ± 1.4 PSNR / 0.597 SSIM** (`runs/maptokengs_fixed_best.safetensors`).
|
| 92 |
+
|
| 93 |
+
## Notes / gotchas
|
| 94 |
+
- **Resolution** is capped by stored data: width ≤ ~768 (AV2 stored 775w), height ≤ ~683 (Waymo).
|
| 95 |
+
The loader does aspect-preserving cover+crop, so AV2 (portrait) and Waymo (landscape) aren't
|
| 96 |
+
distorted. Going higher needs re-processing from native sensor frames via `scripts/*_to_unified`.
|
| 97 |
+
- **Eval is held-out SCENES** (av2/val), `s` pinned to `s_max`. Do not eval on train clips
|
| 98 |
+
(in-sample numbers are inflated).
|
| 99 |
+
- **Licenses:** Waymo data — do NOT redistribute (regenerate from your own Waymo access via
|
| 100 |
+
`mapgs/data/convert/waymo_to_unified.py`). AV2 — CC BY-NC-SA 4.0 (attribute Argoverse 2).
|
| 101 |
+
Checkpoints — derived from NVIDIA TokenGS, research-only / non-commercial.
|