Flor commited on
Commit
21c4ffe
·
0 Parent(s):

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +118 -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,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "depth-estimation"
4
+ license: "other"
5
+ license_name: "mit-code-weights-unstated"
6
+ license_link: "https://github.com/isl-org/MiDaS/blob/454597711a62eabcbf7d1e89f3fb9f569051ac9b/LICENSE"
7
+ tags:
8
+ - "depth"
9
+ - "mono-depth"
10
+ - "monocular-depth"
11
+ - "cuda"
12
+ - "pytorch"
13
+ - "fastforks"
14
+ ---
15
+ # MiDaS v3.1 (fastforks)
16
+
17
+ MiDaS v3.1 (Birkl et al. 2023): relative monocular depth from a BEiT-L/16 encoder and a DPT decoder, trained on a mix of 12 depth datasets.
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/isl-org/MiDaS> at `4545977`.
20
+
21
+ Task: depth. Tier: experimental. Outputs: `inverse_depth`. Backends: `portable`, `kernels`.
22
+
23
+ Input: one RGB image. Output: a depth or inverse-depth map. `kind` (a card field, `result.kind`) says what the numbers mean: `metric` = metres; `scale_invariant`, `affine_invariant` and `affine_invariant_inverse` are relative (unknown scale or shift, not metres). Metric models that use the focal length take `model(image, intrinsics=K)` (K `[3, 3]`, pixels of the input): `metric3d-vit-large` and `da3metric-large` need it for correct metres (`da3metric-large`: metres = output x focal / 300; without `intrinsics=` a 300 px focal length is assumed, wrong for a real camera). `unidepth-v2-vitl14`, `unik3d-vitl`, `depth-pro` and MoGe estimate the camera themselves (given `intrinsics=` replace `fx`); `zoedepth-nk` and the relative models (`da3mono-large` too) take none.
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/depth/models/midas/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `midas-dpt-beit-large-512@1` | [dpt_beit_large_512.pt](https://github.com/isl-org/MiDaS/releases/download/v3_1/dpt_beit_large_512.pt) | `9e9e900747e9` | MIT (assumed from code) | yes |
32
+
33
+ ## Licence
34
+
35
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Files: `LICENSE`.
36
+
37
+ Code licence: MIT; the authors do not state a separate weights licence.
38
+
39
+ Training data: 12 datasets (ReDWeb, DIML, Movies, MegaDepth, WSVD, TartanAir, HRWSI, ApolloScape, BlendedMVS, IRS, KITTI, NYU Depth V2) per the MiDaS v3.1 paper (arXiv 2307.14460).
40
+
41
+ Licence evidence: https://github.com/isl-org/MiDaS/blob/454597711a62eabcbf7d1e89f3fb9f569051ac9b/LICENSE (weights are release assets of the same repository)
42
+
43
+ ## Input size
44
+
45
+ any H x W >= 8, resized or padded inside the model
46
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `midas-dpt-beit-large-512` 3000x4000 (1.8 GiB peak allocated, 1.9 reserved)
47
+
48
+ ## Speed and memory
49
+
50
+ ### Depth, Middlebury 2014 half, 994x1482
51
+
52
+ | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
53
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
54
+ | `midas-dpt-beit-large-512` | 386 | 333 | 78.8 | 63.9 | 5.2x | 1.2x | 2759 / 2898 | 992 / 1418 | 1003 / 1436 |
55
+
56
+ ### Startup and first call
57
+
58
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
59
+ | --- | --- | --- | --- | --- | --- | --- |
60
+ | `midas-dpt-beit-large-512` | 5.16 | 2.49 | 0.28† | 1.14 | 0.09 | 0.07 |
61
+
62
+ ### torch.compile and TensorRT
63
+
64
+ | 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) |
65
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
66
+ | `midas-dpt-beit-large-512` | 994x1482 | 78.8 | 58.8 | 32.6 | 52.2 | 54 | 63.9 | 992 / 1418 | 1088 / 1116 | 800 |
67
+
68
+ ### Fixed-size speed and peak memory, all models
69
+
70
+ | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
71
+ | --- | --- | --- | --- | --- | --- |
72
+ | `midas-dpt-beit-large-512` | portable | 79.3 ms / 1729 / 1880 | 141.1 ms / 1870 / 2052 | 141.2 ms / 1883 / 2080 | 81.6 ms / 1863 / 1990 |
73
+ | `midas-dpt-beit-large-512` | kernels | 52.1 ms / 922 / 1048 | 96.0 ms / 1012 / 1220 | 96.0 ms / 1025 / 1280 | 53.1 ms / 1077 / 1178 |
74
+
75
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
76
+
77
+ Resizes to its working resolution: time depends on the aspect ratio, not the input pixels.
78
+
79
+ 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.
80
+
81
+ ## Accuracy
82
+
83
+ ### On public datasets
84
+
85
+ AbsRel / delta1 after a least-squares scale + shift fit (in disparity space for inverse-depth models), mean over images. Original = the authors' code, same checkpoint and protocol.
86
+
87
+ | variant | dataset | original fp32 | portable | kernels | note |
88
+ |---|---|---|---|---|---|
89
+ | `midas-dpt-beit-large-512` | NYUv2 test, AbsRel / delta1 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | 0.0487 / 0.9789 | |
90
+ | `midas-dpt-beit-large-512` | iBims-1, AbsRel / delta1 | 0.0477 / 0.9727 | 0.0478 / 0.9726 | 0.0478 / 0.9726 | |
91
+ | `midas-dpt-beit-large-512` | ETH3D two-view train left, AbsRel / delta1 | 0.0904 / 0.8978 | 0.0906 / 0.8977 | 0.0908 / 0.8972 | possibly in the training data |
92
+ | `midas-dpt-beit-large-512` | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0425 / 0.9906 | 0.0424 / 0.9906 | 0.0425 / 0.9906 | possibly in the training data |
93
+
94
+ Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-27.
95
+
96
+ ### Parity with the original code
97
+
98
+ Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.02 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.5 % and p99 <= 2 % of the reference's median |value| (absolute error of the output `inverse_depth`).
99
+
100
+ ## Usage
101
+
102
+ ```python
103
+ from fastforks import depth
104
+
105
+ model = depth.load("midas-dpt-beit-large-512") # mode="auto": the preferred backend from recorded measurements
106
+ result = model("room.jpg")
107
+ result.inverse_depth # [H, W] float32 tensor; result.kind says what the maps mean
108
+ # models that take a camera: model("room.jpg", intrinsics=K), K [3, 3] in pixels
109
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
110
+ ```
111
+
112
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `midas-dpt-beit-large-512`.
113
+
114
+ ## Kernels backend
115
+
116
+ `depth.load("midas-dpt-beit-large-512", mode="kernels")` runs our CUDA kernels (`cudnn_hacc`). 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.
117
+
118
+ <!-- staged from fastforks feccac41 (2026-11-06) -->