Flor commited on
Commit
3c1284d
·
0 Parent(s):

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +131 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "depth-estimation"
4
+ license: "other"
5
+ license_name: "nvidia-source-code-license-nc"
6
+ license_link: "https://github.com/NVlabs/FoundationStereo/blob/6e8806816b533e4d13ddbb95ffa907b797060a62/readme.md#L158"
7
+ tags:
8
+ - "stereo"
9
+ - "stereo-matching"
10
+ - "disparity"
11
+ - "cuda"
12
+ - "pytorch"
13
+ - "fastforks"
14
+ ---
15
+ # FoundationStereo (fastforks)
16
+
17
+ FoundationStereo (Wen et al. 2025): zero-shot stereo foundation model with Depth Anything ViT + CNN features, a 3-D regularised cost volume with a disparity transformer and selective ConvGRU updates, 32 iterations.
18
+
19
+ 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/NVlabs/FoundationStereo> at `6e8806816b53`.
20
+
21
+ Task: stereo. Tier: stable. Outputs: `disparity`. Backends: `portable`, `kernels`.
22
+
23
+ Input: a rectified left / right image pair. Output: a disparity map (pixels, left view).
24
+
25
+ ## Variants
26
+
27
+ 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/foundationstereo/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `foundationstereo-vit-l@1` | [23-51-11/model_best_bp2.pth](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1Yh_2o9QCUrVqZrnAXZ7RUr0zTp3JrMKe) | `60e79bde9c6a` | LicenseRef-NVIDIA-Source-Code-License-NC | **no** |
32
+ | `foundationstereo-vit-s@1` | [11-33-40/model_best_bp2.pth](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1Ei-EBaF3EQA977zdjbXdmoXE7WuyJ1ib) | `8d7850b9dc68` | LicenseRef-NVIDIA-Source-Code-License-NC | **no** |
33
+
34
+ ## Licence
35
+
36
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: LicenseRef-NVIDIA-Source-Code-License-NC AND Apache-2.0. Files: `LICENSE`.
37
+
38
+ Training data: Foundation Stereo Dataset (FSD, synthetic, NVIDIA) plus SceneFlow, Falling Things, Sintel, CREStereo, InStereo2K and others; no per-dataset terms checked.
39
+
40
+ - Licence note: Code and weights are under the NVIDIA Source Code License-NC (non-commercial research use only). Our kernels for this family count as derived work and inherit the NC limit; the family ships in fastforks-nc.
41
+
42
+ Licence evidence: <https://github.com/NVlabs/FoundationStereo/blob/6e8806816b533e4d13ddbb95ffa907b797060a62/readme.md#L158>
43
+
44
+ ## Input size
45
+
46
+ any H x W >= 32, padded to a multiple of 32
47
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `foundationstereo-vit-l` 1988x2880 (7.1 GiB peak allocated, 11.4 reserved); `foundationstereo-vit-s` 1988x2880 (6.5 GiB peak allocated, 10.7 reserved)
48
+
49
+ ## Speed and memory
50
+
51
+ ### Stereo, Middlebury 2014 half, 994x1482
52
+
53
+ | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
54
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
55
+ | `foundationstereo-vit-l` | 9228 | 4237 | 2990 | 1513 | 2.8x | 2.0x | 8286 / 8750 | 3141 / 3436 | 2818 / 3300 |
56
+ | `foundationstereo-vit-s` | 7129 | 3609 | 2514 | 1120 | 3.2x | 2.2x | 6987 / 7280 | 2493 / 2606 | 2169 / 2470 |
57
+
58
+ ### Startup and first call
59
+
60
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
61
+ | --- | --- | --- | --- | --- | --- | --- |
62
+ | `foundationstereo-vit-l` | 10.86 (375x1242) | 1.98 | 1.17† | 2.56 (375x1242) | 2.99† | 1.52† |
63
+ | `foundationstereo-vit-s` | 1.44 (375x1242) | 1.03 | 0.33† | 1.06 (375x1242) | 2.51† | 1.12† |
64
+
65
+ ### torch.compile and TensorRT
66
+
67
+ | 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) |
68
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
69
+ | `foundationstereo-vit-s` | 994x1482 | 2514 | 2044.1 | 211.9 | 1195.8 | 545 | 1120 | 2493 / 2606 | 2822 / 3646 | 2570 |
70
+
71
+ ### Fixed-size speed and peak memory, all models
72
+
73
+ | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
74
+ | --- | --- | --- | --- | --- | --- |
75
+ | `foundationstereo-vit-l` | portable | 577.7 ms / 1654 / 2216 | 1846.4 ms / 2676 / 3370 | 3776.7 ms (n=3) / 3570 / 5048 | OOM |
76
+ | `foundationstereo-vit-l` | kernels | 320.0 ms / 1296 / 1642 | 961.0 ms / 2232 / 2800 | 1788.5 ms / 3254 / 4506 | 9521.9 ms (n=3) / 12653 / 14398 |
77
+ | `foundationstereo-vit-s` | portable | 481.4 ms / 1042 / 1352 | 1508.2 ms / 2047 / 2678 | 3424.1 ms (n=3) / 2900 / 4592 | OOM |
78
+ | `foundationstereo-vit-s` | kernels | 245.6 ms / 685 / 862 | 687.1 ms / 1604 / 2008 | 1499.8 ms / 2585 / 3440 | 8960.9 ms (n=3) / 12058 / 13800 |
79
+
80
+ ### Apple silicon (MPS)
81
+
82
+ | model | `portable` | `kernels` | speed-up |
83
+ | --- | --- | --- | --- |
84
+ | `foundationstereo-vit-s` | 7825 ms / 4304 MiB (float16) | 7383 ms / 4284 MiB | 1.06x |
85
+
86
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
87
+
88
+ 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.
89
+
90
+ ## Accuracy
91
+
92
+ ### On public datasets
93
+
94
+ Original = the authors' code, same checkpoint and protocol.
95
+
96
+ | variant | dataset | original fp32 | original fp16 | portable | kernels | note |
97
+ |---|---|---|---|---|---|---|
98
+ | `foundationstereo-vit-l` | ETH3D two-view train, bad > 1 px % / EPE | 0.65 / 0.168 | 0.65 / 0.168 | 0.65 / 0.168 | 0.65 / 0.168 | possibly in the training data |
99
+ | `foundationstereo-vit-l` | Middlebury 2014 trainingH, bad > 2 px % / EPE | 2.48 / 0.562 | 2.48 / 0.561 | 2.47 / 0.561 | 2.48 / 0.561 | possibly in the training data |
100
+ | `foundationstereo-vit-s` | ETH3D two-view train, bad > 1 px % / EPE | 1.10 / 0.202 | 1.10 / 0.202 | 1.10 / 0.202 | 1.10 / 0.202 | possibly in the training data |
101
+ | `foundationstereo-vit-s` | Middlebury 2014 trainingH, bad > 2 px % / EPE | 3.32 / 0.679 | 3.32 / 0.681 | 3.32 / 0.680 | 3.30 / 0.680 | possibly in the training data |
102
+
103
+ Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-05.
104
+
105
+ ### Parity with the original code
106
+
107
+ 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.02 px and p99 <= 0.25 px.
108
+
109
+ ## Limitations
110
+
111
+ - ONNX export needs torch >= 2.14 (older exporters fail on this network).
112
+
113
+ ## Usage
114
+
115
+ ```python
116
+ from fastforks import stereo
117
+
118
+ # non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
119
+ model = stereo.load("foundationstereo-vit-l") # mode="auto": the preferred backend from recorded measurements
120
+ result = model("left.png", "right.png")
121
+ result.disparity # [H, W] float32 tensor, input resolution
122
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
123
+ ```
124
+
125
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `foundationstereo-vit-l`, `foundationstereo-vit-s`.
126
+
127
+ ## Kernels backend
128
+
129
+ `stereo.load("foundationstereo-vit-l", mode="kernels")` runs our CUDA kernels (`fs`, `fs_cutlass`, `cudnn_hacc`, `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.
130
+
131
+ <!-- staged from fastforks feccac41 (2026-11-06) -->