Flor commited on
Commit
1d5cba2
·
0 Parent(s):

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +104 -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,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "depth-estimation"
4
+ license: "other"
5
+ license_name: "research-only"
6
+ license_link: "https://github.com/apple/ml-depth-pro/blob/9e65e4d/README.md"
7
+ tags:
8
+ - "depth"
9
+ - "mono-depth"
10
+ - "monocular-depth"
11
+ - "cuda"
12
+ - "pytorch"
13
+ - "fastforks"
14
+ ---
15
+ # Depth Pro (fastforks)
16
+
17
+ Depth Pro (Bochkovskii et al. 2024, Apple): sharp monocular metric depth from three DINOv2 ViT-L/16 encoders (35 overlapping windows of a 3-level image pyramid, the whole image, the field of view) and a multi-resolution conv decoder at 1536x1536; also estimates the focal length.
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/apple/ml-depth-pro> at `9e65e4d`.
20
+
21
+ Task: depth. Tier: experimental. Outputs: `depth`, `intrinsics`. 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/depth_pro/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `depth-pro@1` | [depth_pro.pt](https://ml-site.cdn-apple.com/models/depth-pro/depth_pro.pt) | `3eb35ca68168` | LicenseRef-research-only | **no** |
32
+
33
+ ## Licence
34
+
35
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: LicenseRef-Apple-Sample-Code. Files: `LICENSE`.
36
+
37
+ Training data: Mixture of real and synthetic metric-depth datasets per the Depth Pro paper (Table 15); the list is not on the model card.
38
+
39
+ - Licence note: The Apple sample-code licence and the model licence allow research use only.
40
+
41
+ Licence evidence: https://github.com/apple/ml-depth-pro/blob/9e65e4d/README.md (License section: code and weights under LICENSE, the Apple sample-code licence) and https://huggingface.co/apple/DepthPro (license: apple-amlr, research use only); the stricter model-card terms are recorded for the weights
42
+
43
+ ## Input size
44
+
45
+ any H x W >= 8, resized or padded inside the model (ViT patch 16)
46
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `depth-pro` 3000x4000 (3.4 GiB peak allocated, 4.0 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
+ | `depth-pro` | 1776 | 569 | 518 | 271 | 2.1x | 1.9x | 3828 / 4294 | 3306 / 3498 | 3667 / 3778 |
55
+
56
+ ### Startup and first call
57
+
58
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
59
+ | --- | --- | --- | --- | --- | --- | --- |
60
+ | `depth-pro` | 17.34 | 4.67 | 1.11† | 0.74 | 0.58 | 0.37 |
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
+ | `depth-pro` | 994x1482 | 518 | 487.8 | 39.2 | 298.8 | 163 | 271 | 3306 / 3498 | 3053 / 3198 | 2926 |
67
+
68
+ ### Fixed-size speed and peak memory, all models
69
+
70
+ | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
71
+ | --- | --- | --- | --- | --- | --- |
72
+ | `depth-pro` | portable | 558.6 ms / 3317 / 4044 | 558.7 ms / 3323 / 4080 | 559.0 ms / 3337 / 4084 | 562.3 ms / 3451 / 4120 |
73
+ | `depth-pro` | kernels | 272.9 ms / 3621 / 4372 | 272.1 ms / 3628 / 4388 | 271.8 ms / 3641 / 4386 | 274.9 ms / 3754 / 4500 |
74
+
75
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
76
+
77
+ 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.
78
+
79
+ ## Accuracy
80
+
81
+ ### Parity with the original code
82
+
83
+ Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.005 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1 % and p99 <= 3 % of the reference's median |value| (absolute error of the output `depth`).
84
+
85
+ ## Usage
86
+
87
+ ```python
88
+ from fastforks import depth
89
+
90
+ # non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
91
+ model = depth.load("depth-pro") # mode="auto": the preferred backend from recorded measurements
92
+ result = model("room.jpg")
93
+ result.depth # [H, W] float32 tensor; result.kind says what the maps mean
94
+ # models that take a camera: model("room.jpg", intrinsics=K), K [3, 3] in pixels
95
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
96
+ ```
97
+
98
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `depth-pro`.
99
+
100
+ ## Kernels backend
101
+
102
+ `depth.load("depth-pro", mode="kernels")` runs our CUDA kernels (`fastbb`, `dpt_fused`). 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.
103
+
104
+ <!-- staged from fastforks feccac41 (2026-11-06) -->