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: experimental. 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. 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, 1536x1024

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
patchmatchnet 248.06 219.74 201.66 29.57 7.4x 6.8x 1228 / 1272 1806 / 2096 740 / 856

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
patchmatchnet 0.04 (1536x1024) 0.06 (1536x1024) 0.05โ€  (1536x1024) 0.92 (1536x1024) 0.25 (1536x1024) 0.04 (1536x1024)

Fixed-size speed and peak memory, all models

model mode 640x480 1280x720 1920x1080 12 MP 4000x3000
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 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.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 % and p99 <= 3 % of the reference's median |value|.

Usage

from fastforks import multiview

model = multiview.load("patchmatchnet")  # portable PyTorch on the GPU if there is one, else the CPU
result = model(["view0.jpg", "view1.jpg", "view2.jpg"])  # the views of one scene
result.depth  # [V, H, W] float32 tensor; result.kind says what the maps mean
# calibrated MVS: model(views, intrinsics=K, cam_to_world=c2w), K [N, 3, 3], c2w [N, 4, 4]
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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support