nmrf / README.md
Flor's picture
Model card synced with fastforks 7204e33f
9c1c865 verified
|
Raw History Blame Contribute Delete
5.55 kB
---
library_name: "fastforks"
pipeline_tag: "depth-estimation"
license: "other"
license_name: "mit-code-weights-unstated"
license_link: "https://github.com/aeolusguan/NMRF/blob/a50bd8f407ae481c38f95cf141e1b5256e962cb7/README.md#L103"
tags:
- "stereo"
- "stereo-matching"
- "disparity"
- "cuda"
- "pytorch"
- "fastforks"
---
# NMRF (fastforks)
NMRF (Guan et al. 2024): neural Markov random field with disparity proposals from a group-wise cost volume, CSWin label-seed propagation and window-attention inference at 1/8 resolution plus a 1/4 refinement.
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/aeolusguan/NMRF> at `a50bd8f407ae`.
Task: stereo. Tier: experimental. Outputs: `disparity`. Backends: `portable`, `kernels`.
Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
## 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/stereo/models/nmrf/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `nmrf-sceneflow@1` | [sceneflow.pth](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1VI-vyMIeNs_jMD6TVTNqFl70nQVgMSIR) | `e7c4a0a4bfe5` | MIT (assumed from code) | yes |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: `LICENSE`.
Code licence: MIT; the authors do not state a separate weights licence.
Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa).
Licence evidence: <https://github.com/aeolusguan/NMRF/blob/a50bd8f407ae481c38f95cf141e1b5256e962cb7/README.md#L103>
## Input size
any H x W >= 9, padded to a multiple of 8
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `nmrf-sceneflow` 3000x4000 (11.0 GiB peak allocated, 13.3 reserved)
## Speed and memory
### Stereo, 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 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `nmrf-sceneflow` | 445.3 | 312.6 | 216.44 | 195.66 | 1.6x | 1.1x | 1656 / 2054 | 1510 / 1552 | 1022 / 1112 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `nmrf-sceneflow` | 0.21 (375x1242) | 0.10 | 0.07† | 0.77 (375x1242) | 0.22† | 0.20† |
### 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) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `nmrf-sceneflow` | 994x1482 | 216.44 | 160.8 | 84.8 | 183.7 | 142 | 195.66 | 1510 / 1552 | 854 / 1104 | 826 |
### Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
| --- | --- | --- | --- | --- | --- |
| `nmrf-sceneflow` | portable | 35.9 ms / 390 / 454 | 124.3 ms / 953 / 1094 | 315.1 ms / 2040 / 2402 | 2021.2 ms (n=3) / 11263 / 13666 |
| `nmrf-sceneflow` | kernels | 31.7 ms / 247 / 298 | 112.1 ms / 626 / 800 | 286.8 ms / 1356 / 1814 | 1834.3 ms / 7543 / 10866 |
### Apple silicon (MPS)
| model | `portable` | `kernels` | speed-up |
| --- | --- | --- | --- |
| `nmrf-sceneflow` | 455 ms / 2408 MiB (float32) | 365 ms / 1425 MiB | 1.24x |
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.05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 px and p99 <= 0.5 px.
## Usage
```python
from fastforks import stereo
model = stereo.load("nmrf-sceneflow") # mode="auto": the preferred backend from recorded measurements
result = model("left.png", "right.png")
result.disparity # [H, W] float32 tensor, input resolution
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: `nmrf-sceneflow`.
## Kernels backend
`stereo.load("nmrf-sceneflow", mode="kernels")` runs our CUDA kernels (`fastbb`). 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) -->