card: update from fastforks 1cbf1671
Browse files
README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "depth-estimation"
|
| 4 |
+
license: "other"
|
| 5 |
+
license_name: "see-model-card"
|
| 6 |
+
license_link: "https://github.com/CompVis/depth-fm/blob/da632c8118e41cc64ca191a13314e2db1a7722d9/README.md"
|
| 7 |
+
tags:
|
| 8 |
+
- "depth"
|
| 9 |
+
- "mono-depth"
|
| 10 |
+
- "monocular-depth"
|
| 11 |
+
- "cuda"
|
| 12 |
+
- "pytorch"
|
| 13 |
+
- "fastforks"
|
| 14 |
+
- "fastforks-card"
|
| 15 |
+
---
|
| 16 |
+
# DepthFM (fastforks)
|
| 17 |
+
|
| 18 |
+
DepthFM (Gui et al. 2024): affine-invariant monocular depth by flow matching from the image latent to the depth latent; a Stable Diffusion 2.1 UNet fine-tuned to the flow, a few Euler steps, ensemble of noise samples (v1).
|
| 19 |
+
|
| 20 |
+
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/CompVis/depth-fm> at `da632c8`.
|
| 21 |
+
|
| 22 |
+
Author weight repos: <https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5>.
|
| 23 |
+
|
| 24 |
+
Task: depth. Tier: experimental. Outputs: `depth`. Backends: `portable`, `kernels`.
|
| 25 |
+
|
| 26 |
+
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`, `affine_invariant_log` (log depth) 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. Normals-only models (`kind` `none`) return `result.normals` `[B, H, W, 3]` (unit vectors, camera frame: x right, y down, z forward).
|
| 27 |
+
|
| 28 |
+
## Variants
|
| 29 |
+
|
| 30 |
+
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/depthfm/card.toml).
|
| 31 |
+
|
| 32 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 33 |
+
|---|---|---|---|---|
|
| 34 |
+
| `depthfm-v1@1` | [depthfm-v1.ckpt](https://ommer-lab.com/files/depthfm/depthfm-v1.ckpt)<br>[vae/diffusion_pytorch_model.safetensors](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/451f4fe16113bff5a5d2269ed5ad43b0592e9a14/vae/diffusion_pytorch_model.safetensors) | `8364b475b525`<br>`a2b5134f4dbc` | LicenseRef-CreativeML-OpenRAIL-PlusPlus-M AND LicenseRef-CreativeML-OpenRAIL-M | yes |
|
| 35 |
+
|
| 36 |
+
## Licence
|
| 37 |
+
|
| 38 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: `LICENSE`, `LICENSE-MODEL`, `LICENSE-VAE`.
|
| 39 |
+
|
| 40 |
+
Training data: Stable Diffusion 2.1 (LAION-5B subsets) fine-tuned on the synthetic Hypersim and Virtual KITTI 2 datasets per the DepthFM paper (arXiv 2403.13788).
|
| 41 |
+
|
| 42 |
+
- Licence note: The UNet is fine-tuned from Stable Diffusion 2.1 (OpenRAIL++-M) and runs with the Stable Diffusion 1.5 VAE (OpenRAIL-M): commercial use is allowed but with use restrictions that must be passed on; the training data terms are not checked.
|
| 43 |
+
|
| 44 |
+
Licence evidence: https://github.com/CompVis/depth-fm/blob/da632c8118e41cc64ca191a13314e2db1a7722d9/README.md (fine-tuned from Stable Diffusion v2-1; code MIT); SD2 licence text from https://huggingface.co/sd2-community/stable-diffusion-2/blob/2511124fabf8bf30c0ca9dccd9729e7f0f2fa669/LICENSE-MODEL, SD1.5 VAE licence https://github.com/CompVis/stable-diffusion/blob/21f890f9da3cfbeaba8e2ac3c425ee9e998d5229/LICENSE
|
| 45 |
+
|
| 46 |
+
## Input size
|
| 47 |
+
|
| 48 |
+
any H x W >= 1, resized or padded inside the model
|
| 49 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `depthfm-v1` 1024x1024 (9.8 GiB peak allocated, 15.0 reserved)
|
| 50 |
+
|
| 51 |
+
## Speed and memory
|
| 52 |
+
|
| 53 |
+
### Depth, synthetic
|
| 54 |
+
|
| 55 |
+
| model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 56 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 57 |
+
| `depthfm-v1` | 994x1482 | β | β | 5662 | β | β | β | β | 13651 / 15150 | β |
|
| 58 |
+
|
| 59 |
+
### Startup and first call
|
| 60 |
+
|
| 61 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 62 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 63 |
+
| `depthfm-v1` | β | 3.58 | β | β | 6.00 | β |
|
| 64 |
+
|
| 65 |
+
### torch.compile and TensorRT
|
| 66 |
+
|
| 67 |
+
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|
| 68 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 69 |
+
| `depthfm-v1` | 994x1482 | 5662 ms | deferred (build >5 min) | deferred (build >5 min) | β | β | β | 13651 / 15150 | β | β | β |
|
| 70 |
+
|
| 71 |
+
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
|
| 72 |
+
|
| 73 |
+
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above 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.
|
| 74 |
+
|
| 75 |
+
## Accuracy
|
| 76 |
+
|
| 77 |
+
### Parity with the original code
|
| 78 |
+
|
| 79 |
+
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.0001 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`).
|
| 80 |
+
|
| 81 |
+
## Limitations
|
| 82 |
+
|
| 83 |
+
- Flow model on a noised latent: the seeded noise comes from a CPU generator and differs from the original code's device generator for the same seed.
|
| 84 |
+
- A traced or exported module reuses the noise of its traced shape.
|
| 85 |
+
- The network input sides are rounded to multiples of 64, so the aspect ratio changes slightly.
|
| 86 |
+
|
| 87 |
+
## Usage
|
| 88 |
+
|
| 89 |
+
```python
|
| 90 |
+
from fastforks import depth
|
| 91 |
+
|
| 92 |
+
model = depth.load("depthfm-v1") # mode="auto": the preferred backend from recorded measurements
|
| 93 |
+
result = model("room.jpg")
|
| 94 |
+
result.depth # [H, W] float32 tensor; result.kind says what the maps mean
|
| 95 |
+
# models that take a camera: model("room.jpg", intrinsics=K), K [3, 3] in pixels
|
| 96 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `depthfm-v1`.
|
| 100 |
+
|
| 101 |
+
## Kernels backend
|
| 102 |
+
|
| 103 |
+
`depth.load("depthfm-v1", 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.
|
| 104 |
+
|
| 105 |
+
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->
|