Commit ·
2d0d91c
0
Parent(s):
fastforks 0.1.0
Browse files- .gitattributes +35 -0
- README.md +116 -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,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "depth-estimation"
|
| 4 |
+
license: "other"
|
| 5 |
+
license_name: "creativeml-openrail-plusplus-m"
|
| 6 |
+
license_link: "https://huggingface.co/prs-eth/marigold-depth-v1-1/blob/9571e7123e258cf052b4e54241f17971c290e9a8/README.md"
|
| 7 |
+
tags:
|
| 8 |
+
- "depth"
|
| 9 |
+
- "mono-depth"
|
| 10 |
+
- "monocular-depth"
|
| 11 |
+
- "cuda"
|
| 12 |
+
- "pytorch"
|
| 13 |
+
- "fastforks"
|
| 14 |
+
---
|
| 15 |
+
# Marigold (fastforks)
|
| 16 |
+
|
| 17 |
+
Marigold (Ke et al. 2023): affine-invariant monocular depth by diffusion; a Stable Diffusion 2 UNet fine-tuned to denoise a depth latent conditioned on the image latent (depth v1-1, few DDIM steps).
|
| 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/prs-eth/Marigold> at `2bfbdea`.
|
| 20 |
+
|
| 21 |
+
Author weight repos: <https://huggingface.co/prs-eth/marigold-depth-v1-1>.
|
| 22 |
+
|
| 23 |
+
Task: depth. Tier: experimental. Outputs: `depth`. Backends: `portable`, `kernels`.
|
| 24 |
+
|
| 25 |
+
Input: one RGB image. Output: a depth or inverse-depth map (metric for the models marked `metric`).
|
| 26 |
+
|
| 27 |
+
## Variants
|
| 28 |
+
|
| 29 |
+
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/marigold/card.toml).
|
| 30 |
+
|
| 31 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 32 |
+
|---|---|---|---|---|
|
| 33 |
+
| `marigold-depth-v1-1@1` | [unet/diffusion_pytorch_model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/unet/diffusion_pytorch_model.safetensors)<br>[vae/diffusion_pytorch_model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/vae/diffusion_pytorch_model.safetensors)<br>[text_encoder/model.safetensors](https://huggingface.co/prs-eth/marigold-depth-v1-1/resolve/9571e7123e258cf052b4e54241f17971c290e9a8/text_encoder/model.safetensors) | `ad9342d79bb5`<br>`a1d993488569`<br>`cce6febb0b6d` | LicenseRef-CreativeML-OpenRAIL-PlusPlus-M | yes |
|
| 34 |
+
|
| 35 |
+
## Licence
|
| 36 |
+
|
| 37 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: `LICENSE`, `LICENSE-MODEL`, `LICENSE-huggingface`.
|
| 38 |
+
|
| 39 |
+
Training data: Stable Diffusion 2 (LAION-5B subsets) fine-tuned on the synthetic Hypersim and Virtual KITTI 2 datasets per the Marigold papers (arXiv 2312.02145, 2505.09358).
|
| 40 |
+
|
| 41 |
+
- Licence note: The weights use the OpenRAIL++-M licence: commercial use is allowed but with use restrictions that must be passed on; the training data terms are not checked.
|
| 42 |
+
|
| 43 |
+
Licence evidence: https://huggingface.co/prs-eth/marigold-depth-v1-1/blob/9571e7123e258cf052b4e54241f17971c290e9a8/README.md (License: CreativeML Open RAIL++-M)
|
| 44 |
+
|
| 45 |
+
## Input size
|
| 46 |
+
|
| 47 |
+
any H x W >= 8, resized or padded inside the model
|
| 48 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `marigold-depth-v1-1` 3000x4000 (3.0 GiB peak allocated, 3.8 reserved)
|
| 49 |
+
|
| 50 |
+
## Speed and memory
|
| 51 |
+
|
| 52 |
+
### Depth, Middlebury 2014 half, 994x1482
|
| 53 |
+
|
| 54 |
+
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 55 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 56 |
+
| `marigold-depth-v1-1` | 975.6 | – | 408.07 | 383.17 | – | 1.1x | – | 2817 / 3760 | 2583 / 3762 |
|
| 57 |
+
|
| 58 |
+
### Startup and first call
|
| 59 |
+
|
| 60 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 61 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 62 |
+
| `marigold-depth-v1-1` | 1.73 | 8.20 | 1.10† | 1.06 | 0.56 | 0.52 |
|
| 63 |
+
|
| 64 |
+
### Fixed-size speed and peak memory, all models
|
| 65 |
+
|
| 66 |
+
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|
| 67 |
+
| --- | --- | --- | --- | --- | --- |
|
| 68 |
+
| `marigold-depth-v1-1` | portable | 455.3 ms / 2898 / 3650 | 351.7 ms / 2648 / 3306 | 351.8 ms / 2661 / 3378 | 458.1 ms / 3033 / 3844 |
|
| 69 |
+
| `marigold-depth-v1-1` | kernels | 433.0 ms / 2636 / 3464 | 324.3 ms / 2452 / 3070 | 324.9 ms / 2465 / 3142 | 435.6 ms / 2770 / 3552 |
|
| 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 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.
|
| 74 |
+
|
| 75 |
+
## Accuracy
|
| 76 |
+
|
| 77 |
+
### On public datasets
|
| 78 |
+
|
| 79 |
+
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.
|
| 80 |
+
|
| 81 |
+
| variant | dataset | original | portable | kernels | note |
|
| 82 |
+
|---|---|---|---|---|---|
|
| 83 |
+
| `marigold-depth-v1-1` | NYUv2 test, AbsRel / delta1 | 0.0558 / 0.9693 | 0.0561 / 0.9703 | 0.0561 / 0.9703 | |
|
| 84 |
+
| `marigold-depth-v1-1` | iBims-1, AbsRel / delta1 | 0.0498 / 0.9717 | 0.0499 / 0.9722 | 0.0499 / 0.9721 | |
|
| 85 |
+
| `marigold-depth-v1-1` | ETH3D two-view train left, AbsRel / delta1 | 0.1075 / 0.8741 | 0.1141 / 0.8715 | 0.1141 / 0.8715 | possibly in the training data |
|
| 86 |
+
| `marigold-depth-v1-1` | Middlebury 2014 trainingH left, AbsRel / delta1 | 0.0409 / 0.9909 | 0.0413 / 0.9899 | 0.0413 / 0.9899 | possibly in the training data |
|
| 87 |
+
|
| 88 |
+
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, 2026-10-28.
|
| 89 |
+
|
| 90 |
+
### Parity with the original code
|
| 91 |
+
|
| 92 |
+
Every variant is checked against golden 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|.
|
| 93 |
+
|
| 94 |
+
## Limitations
|
| 95 |
+
|
| 96 |
+
- Diffusion model: the seeded noise comes from a CPU generator and differs from the original code's CUDA generator for the same seed.
|
| 97 |
+
- A traced or exported module reuses the noise of its traced shape.
|
| 98 |
+
- Kernels time is dominated by unfused elementwise kernels (GroupNorm / SiLU / adds).
|
| 99 |
+
|
| 100 |
+
## Usage
|
| 101 |
+
|
| 102 |
+
```python
|
| 103 |
+
from fastforks import depth
|
| 104 |
+
|
| 105 |
+
model = depth.load("marigold-depth-v1-1") # portable PyTorch on the GPU if there is one, else the CPU
|
| 106 |
+
result = model("room.jpg")
|
| 107 |
+
result.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: `marigold-depth-v1-1`.
|
| 113 |
+
|
| 114 |
+
## Kernels backend
|
| 115 |
+
|
| 116 |
+
`depth.load("marigold-depth-v1-1", 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.
|