Metadata-Version: 2.4
Name: vggtmu
Version: 1.0.0
Summary: VGGT-μ: lightweight relative pose regression at scale.
Author: Ludvig Dillén, David Nordström
Author-email: Ludvig Dillén <ludvig.dillen@math.lth.se>, David Nordström <davnords@chalmers.se>
License-Expression: MIT
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: scipy
Requires-Dist: torch>=2.2
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: torchvision ; extra == 'eval'
Requires-Dist: tqdm ; extra == 'eval'
Requires-Dist: tyro ; extra == 'eval'
Requires-Dist: gtsam==4.3a0 ; extra == 'odometry'
Requires-Dist: tyro ; extra == 'odometry'
Requires-Dist: numpy>=2 ; extra == 'sfm'
Requires-Dist: pycolmap==4.1.1 ; extra == 'sfm'
Requires-Dist: tyro ; extra == 'sfm'
Requires-Dist: torchvision ; extra == 'train'
Requires-Dist: tyro ; extra == 'train'
Requires-Python: >=3.10
Project-URL: Homepage, https://www.davnords.com/vggt-mu
Project-URL: Paper, https://arxiv.org/abs/2604.04931
Project-URL: Repository, https://github.com/davnords/VGGT-Mu
Provides-Extra: dev
Provides-Extra: eval
Provides-Extra: odometry
Provides-Extra: sfm
Provides-Extra: train
Description-Content-Type: text/markdown

<div align="center">
<h1>VGGT-μ: Lightweight Relative Pose Regression at Scale</h1>

<a href="https://arxiv.org/abs/TBD"><img src="https://img.shields.io/badge/arXiv-TBD-b31b1b" alt="arXiv"></a>
<a href="https://www.davnords.com/vggt-mu"><img src="https://img.shields.io/badge/Project_Page-green" alt="Project Page"></a>

[Ludvig Dillén*](https://scholar.google.com/citations?user=vaOyn1AAAAAJ), [David Nordström*](https://scholar.google.com/citations?user=-vJPE04AAAAJ), [Xinyue Zhang](https://scholar.google.com/citations?user=WvixLxcAAAAJ), [Yaroslava Lochman](https://scholar.google.com/citations?user=elZV2kYAAAAJ), [Janne Heikkilä](https://scholar.google.com/citations?user=SCR4RY8AAAAJ), [Fredrik Kahl](https://scholar.google.com/citations?user=P_w6UgMAAAAJ), [Viktor Larsson](https://scholar.google.com/citations?user=vHeD0TYAAAAJ)
</div>

<p align="center">
    <img src="assets/vggtmu.jpg" alt="example" width=100%>
    <br>
    <em>VGGT-μ estimates poses for 1,000 frames in two seconds while being more accurate than VGGT-Ω.</em>
</p>

## Overview
VGGT-μ estimates the cameras of hundreds of images in a single forward pass. It predicts the relative metric pose of every pair of images together with its uncertainty, and turns them into absolute poses by anisotropic pose averaging. It is a 120M-parameter model that loops one pair of frame-attention and global-attention blocks, and processes 500 images in 1.4 s using 5.3 GiB VRAM. Known poses and focal lengths, e.g. of the reference images in visual localization, can optionally be given as input.

## How to Use
```python
from vggtmu import VGGTMu, load_images

model = VGGTMu.from_pretrained().cuda()
images = load_images(["a.jpg", "b.jpg", "c.jpg"]).cuda()  # long side 256
out = model.predict(images)
out["extrinsics"]  # (1, N, 3, 4) camera-from-world, the first camera at the identity
out["intrinsics"]  # (1, N, 3, 3) for the input resolution
out["scale"]       # (1,) metres per unit of the translations
```
`uv run --extra eval demo.py <folder>` writes the cameras of a folder of images to `cameras.npz`. `predict` uses anisotropic pose averaging by default. Known poses and focal lengths are given with `vggtmu.build_conditioning`; the predicted cameras are then in the frame of the given poses (`Conditioning.to_input_frame`).

For a video, `Odometry` tracks frames against cached keyframe blocks and keeps a pose graph with loop closures (`pip install vggtmu[odometry]`):
```python
from vggtmu.odometry import Odometry

vo = Odometry(model)
for image in load_images(video_frames):  # one at a time works too
    vo.add(image)
poses = vo.finish()  # (N, 4, 4) camera-to-world, in metres
```

## Setup/Install
```bash
pip install vggtmu
```
or, from a clone of this repository,
```bash
uv sync
```

## Benchmarks
Run from a clone of this repository; each command installs what its benchmark needs (`--extra eval`, `sfm` or `odometry`). Each benchmark reads its data from `data/` by default; download it yourself as described below. Results are written to `results/`.

**Multi-view relative pose on RealEstate10K.** Download the test split from the [source](https://google.github.io/realestate10k/) and save the frames of each test sequence in order as `data/re10k_test/<sequence>/images/0000.png, 0001.png, ...` (640x360). Our annotations, [re10k_test.jgz](https://github.com/davnords/storage/releases/download/vggtmu-v1.0/re10k_test.jgz), download automatically.
```bash
uv run --extra eval eval.py relpose
```

**Visual localization on Cambridge Landmarks.** The [official release](https://www.repository.cam.ac.uk/handle/1810/251342) of the five scenes in `data/cambridge/<Scene>`. Each query is localized from its 10 nearest training images (NetVLAD), given their poses (`--cond poses`) and also all focal lengths (`--cond poses+focals`).
```bash
uv run --extra eval eval.py visloc --cond poses+focals
```

**Global SfM on IMC 2023.** VGGT-μ's poses and focal lengths seed COLMAP, which triangulates the SIFT matches and runs bundle adjustment. The five `phototourism` scenes of the [IMC 2023](https://www.kaggle.com/competitions/image-matching-challenge-2023) training set in `data/imc2023/train/phototourism/<scene>`. Matching needs a CUDA build of [COLMAP 4.1.1](https://colmap.github.io/install.html); pycolmap has x86-64 wheels only.
```bash
uv run --extra sfm eval.py sfm --colmap /path/to/colmap
```

**Visual odometry on Cambridge Landmarks and ETH3D SLAM.** Eight Cambridge sequences from the official release in `data/cambridge/<Scene>/<seq>`, with the [retriangulated ground truth](https://drive.google.com/file/d/1esqzZ1zEQlzZVic-H32V6kkZvc4NeS15) unzipped into `data/cambridge`. The six ETH3D SLAM training sequences and the official evaluator download to `data/eth3d-slam` on first use (needs CMake and a C++ compiler).
```bash
uv run --extra odometry eval.py odometry --dataset cambridge
uv run --extra odometry eval.py odometry --dataset eth3d
```

**Runtime and memory.**
```bash
uv run --extra eval eval.py complexity
```

### Expected Results
The code in this repository reproduces the paper's numbers.

<details>
<summary>Paper vs. this repository</summary>

| Benchmark | Metric | Paper | This repository |
|---|---|---|---|
| RealEstate10K | AUC@30 / AUC@3 | 92.27 / 55.41 | 92.26 / 55.41 |
| Cambridge, poses | median m / ° / % within (0.5 m, 5°) | 0.31 / 0.32 / 74.0 | 0.31 / 0.32 / 74.1 |
| Cambridge, poses + focals | median m / ° / % within (0.5 m, 5°) | 0.18 / 0.31 / 87.1 | 0.18 / 0.31 / 87.1 |
| Odometry, Cambridge | ATE m / peak VRAM GiB | 1.13 / 0.6 | 1.09 / 0.63 |
| Odometry, ETH3D SLAM | ATE m / peak VRAM GiB | 0.54 / 0.7 | 0.56 / 0.65 |
| Global SfM, IMC 2023 | AUC@0.5 / 1 / 5 / 10 | 40.6 / 56.2 / 81.3 / 87.0 | 40.6 / 56.2 / 81.3 / 87.0 |
| Runtime, 500 frames | s / GiB (GH200) | 1.4 / 5.3 | 1.36 / 5.30 |

</details>

## Training
Training supervises on ground-truth poses and intrinsics while distilling VGGT-Ω at 256 px on MegaDepth (`data/megadepth` with `prep_scene_info/`, as in [DKM](https://github.com/Parskatt/DKM)). It needs the [DINOv3 ViT-B/16](https://github.com/facebookresearch/dinov3) weights for the encoder and the [VGGT-Ω](https://github.com/facebookresearch/vggt-omega) 256 px checkpoint for the teacher.
```bash
uv sync --extra train
uv pip install git+https://github.com/facebookresearch/vggt-omega
uv run --no-sync torchrun --nproc-per-node 4 train.py --name megadepth \
    --dinov3 dinov3_vitb16_pretrain_lvd1689m-73cec8be.pth --teacher vggt_omega_1b_256_text.pt
```
The released model was trained the same way on a mix of 19 datasets, which this repository does not include.

## Pretrained Weights
The weights download when the model is created. Direct link: [vggtmu.pt](https://github.com/davnords/storage/releases/download/vggtmu-v1.0/vggtmu.pt).

## Checklist
- [ ] Publish a depth head.

## Citation
```bibtex
@article{dillen2026vggtmu,
  title   = {{VGGT-$\mu$}: Lightweight Relative Pose Regression at Scale},
  author  = {Dill{\'e}n, Ludvig and Nordstr{\"o}m, David and Zhang, Xinyue and Lochman, Yaroslava and Heikkil{\"a}, Janne and Kahl, Fredrik and Larsson, Viktor},
  journal = {arXiv preprint arXiv:2604.04931},
  year    = {2026}
}
```

## License
MIT. The DINOv3 encoder weights are under the [DINOv3 License](https://ai.meta.com/resources/models-and-libraries/dinov3-license/).
