PatchmatchNet (fastforks)
PatchmatchNet (Wang et al. 2021): learned PatchMatch multi-view stereo, the depth of a reference view from posed, calibrated source views and a depth search range. Three coarse-to-fine PatchMatch stages (random initialisation, adaptive propagation, group-wise correlation with pixel-wise view weights, adaptive spatial cost aggregation) on FPN features, then a depth refinement net at full resolution.
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/FangjinhuaWang/PatchmatchNet at 8dc6cb4.
Task: multiview. Tier: stable. Outputs: depth, confidence. Backends: portable, kernels.
Input: several images of one scene (posed and calibrated for multi-view stereo, unposed otherwise). Output: depth maps and, where the model predicts them, cameras and 3-D points.
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
patchmatchnet@1 |
params_000007.ckpt | 477b056c6235 |
MIT (assumed from code) | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: LICENSE.
Code licence: MIT; the authors do not state a separate weights licence.
Training data: DTU Robot Image Data Sets (MVS 2014) (The released checkpoint (checkpoints/params_000007.ckpt) is trained on DTU (README); the paper evaluates it zero-shot on Tanks and Temples and ETH3D).
- Licence note: The code is MIT; the checkpoint ships in the repository without a licence of its own (MIT assumed) and is trained on DTU, whose terms of use are not stated.
Licence evidence: https://github.com/FangjinhuaWang/PatchmatchNet/blob/8dc6cb4/LICENSE and README.md (the checkpoint ships in the repository)
Input size
any H x W >= 5, resized or padded inside the model
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): patchmatchnet 1988x2880 (7.9 GiB peak allocated, 9.4 reserved)
Speed and memory
Multiview, synthetic
| model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|---|
patchmatchnet |
1536x1024 | 248 | 220 | 201 | 29.5 | 7.4x | 6.8x | 1228 / 1272 | 1039 / 1212 | 648 / 772 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
patchmatchnet |
0.04 (1536x1024) | 0.16 (1536x1024) | 0.17 (1536x1024) | 0.92 (1536x1024) | 0.86 (1536x1024) | 0.56 (1536x1024) |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
patchmatchnet |
1536x1024 | 201 ms | 175 ms | 51.0 ms | 29.5 ms | 29.4 s | 82.1 s | 1039 / 1212 | 1798 / 1888 | 648 / 772 | 1073 / 1106 |
Fixed-size speed and peak memory, all models
| model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
|---|---|---|---|---|---|
patchmatchnet |
portable | 43.1 ms / 439 / 522 | 154.4 ms / 1242 / 1534 | 408.6 ms / 2753 / 3346 | OOM |
patchmatchnet |
kernels | 9.2 ms / 253 / 328 | 24.4 ms / 693 / 942 | 56.7 ms / 1520 / 2016 | 378.6 ms / 8628 / 11332 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above 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
On public datasets
640x512 crops, the 7 most co-visible views as sources; GT = depth rendered from the structured-light points. AbsRel / delta1 over GT pixels, after per-image median scaling unless the model takes the cameras (calibrated MVS: cameras, error in mm; PatchMatchNet also the depth range 425-935 mm, MVSAnywhere its own range from the camera baselines). Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
patchmatchnet |
DTU scans 1, 9, 24, 33, 75, view 24 + 7 sources, AbsRel / delta1 % / MAE mm | 0.0087 / 99.52 / 7.03 | fails (LinAlgError: linalg.inv) | 0.0087 / 99.52 / 7.08 | 0.0087 / 99.52 / 7.08 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 % and p99 <= 3 % of the reference's median |value| (absolute error of the output depth).
Usage
from fastforks import multiview
model = multiview.load("patchmatchnet") # mode="auto": the preferred backend from recorded measurements
result = model(["ref.jpg", "src1.jpg", "src2.jpg"], intrinsics=K, cam_to_world=c2w, depth_range=(0.5, 5.0))
result.depth # [1, H, W] float32 tensor; views[0] = reference, K [N, 3, 3] pixels, c2w [N, 4, 4] OpenCV
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: patchmatchnet.
Kernels backend
multiview.load("patchmatchnet", mode="kernels") runs our CUDA kernels (patchmatchnet). 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.