--- library_name: "fastforks" pipeline_tag: "depth-estimation" license: "other" license_name: "mit-code-weights-unstated" license_link: "https://github.com/JiaRenChang/PSMNet/blob/87ac9093afbf6545c093bd9d26c5ffd66e49a7b8/README.md#L96-L98" tags: - "stereo" - "stereo-matching" - "disparity" - "cuda" - "pytorch" - "fastforks" --- # PSMNet (fastforks) PSMNet (Chang and Chen 2018): spatial-pyramid features, a concatenation 3-D cost volume with three stacked 3-D hourglasses and soft-argmin regression (max disparity 192). 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: . Kernels for the `kernels` backend: . Original code: at `87ac9093afbf`. 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/psmnet/card.toml). | variant | weights (author link) | SHA-256 | weights licence | commercial use | |---|---|---|---|---| | `psmnet-sceneflow@1` | [pretrained_sceneflow_new.tar](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1NDKrWHkwgMKtDwynXVU12emK3G5d5kkp) | `eb3029f7ed5e` | 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: ## Input size any H x W >= 241, padded to a multiple of 16 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `psmnet-sceneflow` 1988x2880 (7.6 GiB peak allocated, 10.6 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 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `psmnet-sceneflow` | 759.6 | 607.8 | 339.98 | 231.81 | 2.6x | 1.5x | 6015 / 6090 | 2078 / 2442 | 1786 / 2122 | ### Startup and first call | model | load (s): original | portable | kernels | first call (s): original | portable | kernels | | --- | --- | --- | --- | --- | --- | --- | | `psmnet-sceneflow` | 0.20 (375x1242) | 0.10 | 0.08† | 0.53 (375x1242) | 0.35† | 0.23† | ### 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) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `psmnet-sceneflow` | 994x1482 | 339.98 | 439.9 | 60.0 | 668.8 | 89 | 231.81 | 2078 / 2442 | 1760 / 2082 | 1528 | ### Fixed-size speed and peak memory, all models | model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 | | --- | --- | --- | --- | --- | --- | | `psmnet-sceneflow` | portable | 69.0 ms / 426 / 606 | 206.2 ms / 1256 / 1780 | 479.2 ms / 2834 / 3966 | OOM | | `psmnet-sceneflow` | kernels | 49.6 ms / 415 / 518 | 140.3 ms / 1108 / 1414 | 329.2 ms / 2459 / 3104 | OOM | 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.002 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("psmnet-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 ). Other variants: `psmnet-sceneflow`. ## Kernels backend `stereo.load("psmnet-sceneflow", mode="kernels")` runs our CUDA kernels (`igev`, `cutlass_conv`, `cudnn_hacc`). It needs a prebuilt kernel for your GPU architecture (downloaded from 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.