moge / README.md
Flor's picture
Model card synced with fastforks 7204e33f
4350ef7 verified
|
Raw History Blame Contribute Delete
7.65 kB
---
library_name: "fastforks"
pipeline_tag: "depth-estimation"
license: "mit"
tags:
- "depth"
- "mono-depth"
- "monocular-depth"
- "cuda"
- "pytorch"
- "fastforks"
---
# MoGe (fastforks)
MoGe-2 / MoGe-3 (Wang et al., Microsoft): monocular metric geometry; a DINOv2 ViT with conv heads predicts an affine point map, a validity mask, normals and a metric scale, and the focal length and shift are recovered from the points (MoGe-3 adds a sparse 3-D refiner).
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: <https://github.com/kleinicke/fastforks>. Kernels for the `kernels` backend: <https://huggingface.co/fastforks/kernels>. Original code: <https://github.com/microsoft/MoGe> at `74fbce0`.
Author weight repos: <https://huggingface.co/Ruicheng/moge-2-vitl-normal>, <https://huggingface.co/Ruicheng/moge-2-vits-normal>, <https://huggingface.co/Ruicheng/moge-3-vitl>.
Task: depth. Tier: experimental. Outputs: `depth`, `points`, `intrinsics`, `mask`, `normals`. Backends: `portable`, `kernels`.
Input: one RGB image. Output: a depth or inverse-depth map. `kind` (a card field, `result.kind`) says what the numbers mean: `metric` = metres; `scale_invariant`, `affine_invariant` and `affine_invariant_inverse` are relative (unknown scale or shift, not metres). Metric models that use the focal length take `model(image, intrinsics=K)` (K `[3, 3]`, pixels of the input): `metric3d-vit-large` and `da3metric-large` need it for correct metres (`da3metric-large`: metres = output x focal / 300; without `intrinsics=` a 300 px focal length is assumed, wrong for a real camera). `unidepth-v2-vitl14`, `unik3d-vitl`, `depth-pro` and MoGe estimate the camera themselves (given `intrinsics=` replace `fx`); `zoedepth-nk` and the relative models (`da3mono-large` too) take none.
## Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/depth/models/moge/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `moge-2-vitl-normal@1` | [model.pt](https://huggingface.co/Ruicheng/moge-2-vitl-normal/resolve/main/model.pt) | `280741fd09bc` | MIT | yes |
| `moge-2-vits-normal@1` | [model.pt](https://huggingface.co/Ruicheng/moge-2-vits-normal/resolve/main/model.pt) | `79a16621928c` | MIT | yes |
| `moge-3-vitl@1` | [model.pt](https://huggingface.co/Ruicheng/moge-3-vitl/resolve/main/model.pt) | `9b41b7b9f65a` | MIT | yes |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: `LICENSE`.
Training data: Mixture of public synthetic and real RGB-D / multi-view datasets per the MoGe-2 and MoGe-3 papers.
Licence evidence: https://github.com/microsoft/MoGe/blob/main/README.md (License section) and the Hugging Face model cards (license: mit)
## Input size
any H x W >= 8, resized or padded inside the model (ViT patch 14)
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `moge-2-vitl-normal` 3000x4000 (2.4 GiB peak allocated, 2.5 reserved); `moge-2-vits-normal` 3000x4000 (1.2 GiB peak allocated, 1.4 reserved); `moge-3-vitl` 3000x4000 (2.6 GiB peak allocated, 3.0 reserved)
## Speed and memory
### Depth, Middlebury 2014 half, 994x1482
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `moge-2-vitl-normal` | 501.46 | 170.7 | 144.5 | 73.43 | 2.3x | 2.0x | 2339 / 2438 | 1661 / 1836 | 1498 / 1610 |
| `moge-2-vits-normal` | 161.84 | 82.61 | 64.19 | 29.73 | 2.8x | 2.2x | 1193 / 1268 | 1066 / 1336 | 884 / 1008 |
| `moge-3-vitl` | – | – | 904.91 | 214.048 | – | 4.2x | – | 2157 / 2424 | 1690 / 1844 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `moge-2-vitl-normal` | 7.24 | 1.37 | 0.63† | 0.17 | 0.14 | 0.13 |
| `moge-2-vits-normal` | 0.88 | 0.35 | 0.11† | 1.50 | 0.08 | 0.10 |
| `moge-3-vitl` | – | 1.47 | 1.13 | – | 0.95 | 0.29 |
### torch.compile and TensorRT
| model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `moge-2-vits-normal` | 994x1482 | 64.19 | 43.9 | 123.9 | fails: TensorRT: antialiased resize not supported | – | 29.73 | 1066 / 1336 | 836 / 992 | – |
### Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
| --- | --- | --- | --- | --- | --- |
| `moge-2-vitl-normal` | portable | 175.5 ms / 2275 / 2508 | 178.8 ms / 2286 / 2518 | 179.2 ms / 2299 / 2528 | 191.5 ms / 2410 / 2562 |
| `moge-2-vitl-normal` | kernels | 74.3 ms / 1435 / 1572 | 77.5 ms / 1444 / 1588 | 76.0 ms / 1459 / 1644 | 90.5 ms / 1755 / 2174 |
| `moge-2-vits-normal` | portable | 88.6 ms / 1123 / 1418 | 85.4 ms / 1132 / 1392 | 86.7 ms / 1146 / 1446 | 98.6 ms / 1257 / 1464 |
| `moge-2-vits-normal` | kernels | 33.9 ms / 818 / 970 | 33.1 ms / 826 / 976 | 31.0 ms / 839 / 1010 | 46.9 ms / 1144 / 1566 |
| `moge-3-vitl` | portable | 657.4 ms / 2580 / 3070 | 633.4 ms / 2577 / 2792 | 620.0 ms / 2588 / 2804 | 655.1 ms / 2701 / 3066 |
| `moge-3-vitl` | kernels | 386.2 ms / 1570 / 1836 | 374.2 ms / 1557 / 1840 | 362.3 ms / 1566 / 1890 | 390.6 ms / 1838 / 2300 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
## Accuracy
### Parity with the original code
Every variant is checked against golden outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.005 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.5 % and p99 <= 1.5 % of the reference's median |value| (absolute error of the output `depth`).
## Usage
```python
from fastforks import depth
model = depth.load("moge-2-vitl-normal") # mode="auto": the preferred backend from recorded measurements
result = model("room.jpg")
result.depth # [H, W] float32 tensor; result.kind says what the maps mean
# models that take a camera: model("room.jpg", intrinsics=K), K [3, 3] in pixels
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
```
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `moge-2-vitl-normal`, `moge-2-vits-normal`, `moge-3-vitl`.
## Kernels backend
`depth.load("moge-2-vitl-normal", mode="kernels")` runs our CUDA kernels (`fastbb`, `dpt_fused`, `sparse_conv`). It needs a prebuilt kernel for your GPU architecture (downloaded from <https://huggingface.co/fastforks/kernels> on first use) and a recent NVIDIA driver; if there is none it raises `BackendUnavailableError` with the reason and never falls back silently. `mode="auto"` picks `kernels` when it can run and logs the choice.
<!-- staged from fastforks 7204e33f (2026-11-05) -->