Flor commited on
Commit
47d611f
·
0 Parent(s):

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +99 -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,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "depth-estimation"
4
+ license: "cc-by-nc-4.0"
5
+ tags:
6
+ - "stereo"
7
+ - "stereo-matching"
8
+ - "disparity"
9
+ - "cuda"
10
+ - "pytorch"
11
+ - "fastforks"
12
+ ---
13
+ # BridgeDepth (fastforks)
14
+
15
+ BridgeDepth (Guan et al. 2025): Depth Anything V2 (ViT-L) features combined with NMRF stereo hypotheses; window-attention message passing between mono and stereo embeddings, inference at 1/8 resolution plus a 1/4 refinement.
16
+
17
+ 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/BridgeDepth> at `9a231601e698`.
18
+
19
+ Author weight repos: <https://huggingface.co/aeolusguan/BridgeDepth>.
20
+
21
+ Task: stereo. Tier: experimental. 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/bridgedepth/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `bridgedepth-rvc-pretrain@1` | [bridge_rvc_pretrain.pth](https://huggingface.co/aeolusguan/BridgeDepth/resolve/main/bridge_rvc_pretrain.pth) | `4cb8d0395e67` | CC-BY-NC-4.0 | **no** |
32
+ | `bridgedepth-sf@1` | [bridge_sf.pth](https://huggingface.co/aeolusguan/BridgeDepth/resolve/main/bridge_sf.pth) | `d2cd44b6f749` | CC-BY-NC-4.0 | **no** |
33
+
34
+ ## Licence
35
+
36
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: `LICENSE`, `LICENSE-torchvision`.
37
+
38
+ Training data: Freiburg SceneFlow (FlyingThings3D, Driving, Monkaa).
39
+
40
+ - Licence note: The weights embed Depth Anything V2 weights released under CC-BY-NC-4.0, so they are non-commercial even though the code is MIT.
41
+
42
+ Licence evidence: <https://github.com/aeolusguan/BridgeDepth/blob/9a231601e6981d3536fa6a78ebaccebc1edb99a4/README.md#L40>
43
+
44
+ ## Input size
45
+
46
+ any H x W >= 16, padded to a multiple of 16
47
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `bridgedepth-rvc-pretrain` 3000x4000 (13.3 GiB peak allocated, 14.2 reserved); `bridgedepth-sf` 3000x4000 (13.3 GiB peak allocated, 14.2 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
+ | `bridgedepth-rvc-pretrain` | 628.7 | 470.1 | 441.62 | 353.63 | 1.3x | 1.2x | 2903 / 3200 | 2968 / 3246 | 2361 / 2686 |
56
+ | `bridgedepth-sf` | 616.5 | 459.9 | 436.86 | 348.37 | 1.3x | 1.3x | 2852 / 3144 | 2916 / 3214 | 2310 / 2634 |
57
+
58
+ ### Startup and first call
59
+
60
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
61
+ | --- | --- | --- | --- | --- | --- | --- |
62
+ | `bridgedepth-rvc-pretrain` | 5.87 (375x1242) | 1.84 | 0.76† | 1.36 (375x1242) | 0.45† | 0.36† |
63
+ | `bridgedepth-sf` | 4.86 (375x1242) | 1.53 | 0.72† | 0.12 (375x1242) | 0.44† | 0.35† |
64
+
65
+ ### Fixed-size speed and peak memory, all models
66
+
67
+ | model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
68
+ | --- | --- | --- | --- | --- | --- |
69
+ | `bridgedepth-rvc-pretrain` | portable | 76.7 ms / 1727 / 1798 | 247.2 ms / 2359 / 2628 | 676.5 ms / 3562 / 4102 | 7918.7 ms (n=3) / 13620 / 14590 |
70
+ | `bridgedepth-rvc-pretrain` | kernels | 62.2 ms / 1147 / 1266 | 200.9 ms / 1764 / 2096 | 534.7 ms / 2939 / 3514 | 5573.1 ms (n=3) / 12950 / 13592 |
71
+ | `bridgedepth-sf` | portable | 73.2 ms / 1676 / 1748 | 242.8 ms / 2308 / 2560 | 668.4 ms / 3511 / 4032 | 7849.6 ms (n=3) / 13569 / 14540 |
72
+ | `bridgedepth-sf` | kernels | 59.1 ms / 1096 / 1214 | 196.3 ms / 1714 / 2044 | 526.9 ms / 2888 / 3462 | 5498.6 ms (n=3) / 12898 / 13540 |
73
+
74
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
75
+
76
+ 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.
77
+
78
+ ## Accuracy
79
+
80
+ ### Parity with the original code
81
+
82
+ 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.02 px and p99 <= 0.25 px.
83
+
84
+ ## Usage
85
+
86
+ ```python
87
+ from fastforks import stereo
88
+
89
+ model = stereo.load("bridgedepth-rvc-pretrain") # portable PyTorch on the GPU if there is one, else the CPU
90
+ result = model("left.png", "right.png")
91
+ result.disparity # [H, W] float32 tensor, input resolution
92
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
93
+ ```
94
+
95
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `bridgedepth-rvc-pretrain`, `bridgedepth-sf`.
96
+
97
+ ## Kernels backend
98
+
99
+ `stereo.load("bridgedepth-rvc-pretrain", 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.