Commit ·
8cb5984
0
Parent(s):
fastforks 0.1.0
Browse files- .gitattributes +35 -0
- README.md +98 -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,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "image-to-3d"
|
| 4 |
+
license: "other"
|
| 5 |
+
license_name: "mit-code-weights-unstated"
|
| 6 |
+
license_link: "https://github.com/FangjinhuaWang/PatchmatchNet/blob/8dc6cb4/LICENSE"
|
| 7 |
+
tags:
|
| 8 |
+
- "multiview"
|
| 9 |
+
- "multi-view-stereo"
|
| 10 |
+
- "3d-reconstruction"
|
| 11 |
+
- "camera-pose-estimation"
|
| 12 |
+
- "cuda"
|
| 13 |
+
- "pytorch"
|
| 14 |
+
- "fastforks"
|
| 15 |
+
---
|
| 16 |
+
# PatchmatchNet (fastforks)
|
| 17 |
+
|
| 18 |
+
PatchmatchNet (Wang et al. 2021): learned PatchMatch multi-view stereo, the depth of a reference view from posed, calibrated source views and a depth search range. Three coarse-to-fine PatchMatch stages (random initialisation, adaptive propagation, group-wise correlation with pixel-wise view weights, adaptive spatial cost aggregation) on FPN features, then a depth refinement net at full resolution.
|
| 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/FangjinhuaWang/PatchmatchNet> at `8dc6cb4`.
|
| 21 |
+
|
| 22 |
+
Task: multiview. Tier: experimental. Outputs: `depth`, `confidence`. Backends: `portable`, `kernels`.
|
| 23 |
+
|
| 24 |
+
Input: several images of one scene (posed and calibrated for multi-view stereo, unposed otherwise). Output: depth maps and, where the model predicts them, cameras and 3-D points.
|
| 25 |
+
|
| 26 |
+
## Variants
|
| 27 |
+
|
| 28 |
+
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/multiview/models/patchmatchnet/card.toml).
|
| 29 |
+
|
| 30 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 31 |
+
|---|---|---|---|---|
|
| 32 |
+
| `patchmatchnet@1` | [params_000007.ckpt](https://github.com/FangjinhuaWang/PatchmatchNet/raw/8dc6cb40bdb7053e856598b378425c76a9dcf5e0/checkpoints/params_000007.ckpt) | `477b056c6235` | MIT (assumed from code) | yes |
|
| 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`.
|
| 37 |
+
|
| 38 |
+
Code licence: MIT; the authors do not state a separate weights licence.
|
| 39 |
+
|
| 40 |
+
Training data: DTU Robot Image Data Sets (MVS 2014) (The released checkpoint (checkpoints/params_000007.ckpt) is trained on DTU (README); the paper evaluates it zero-shot on Tanks and Temples and ETH3D).
|
| 41 |
+
|
| 42 |
+
- Licence note: The code is MIT; the checkpoint ships in the repository without a licence of its own (MIT assumed) and is trained on DTU, whose terms of use are not stated.
|
| 43 |
+
|
| 44 |
+
Licence evidence: https://github.com/FangjinhuaWang/PatchmatchNet/blob/8dc6cb4/LICENSE and README.md (the checkpoint ships in the repository)
|
| 45 |
+
|
| 46 |
+
## Input size
|
| 47 |
+
|
| 48 |
+
any H x W >= 5, resized or padded inside the model
|
| 49 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `patchmatchnet` 1988x2880 (7.9 GiB peak allocated, 9.4 reserved)
|
| 50 |
+
|
| 51 |
+
## Speed and memory
|
| 52 |
+
|
| 53 |
+
### Multiview, synthetic, 1536x1024
|
| 54 |
+
|
| 55 |
+
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 56 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 57 |
+
| `patchmatchnet` | 248.06 | 219.74 | 201.66 | 29.57 | 7.4x | 6.8x | 1228 / 1272 | 1806 / 2096 | 740 / 856 |
|
| 58 |
+
|
| 59 |
+
### Startup and first call
|
| 60 |
+
|
| 61 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 62 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 63 |
+
| `patchmatchnet` | 0.04 (1536x1024) | 0.06 (1536x1024) | 0.05† (1536x1024) | 0.92 (1536x1024) | 0.25 (1536x1024) | 0.04 (1536x1024) |
|
| 64 |
+
|
| 65 |
+
### Fixed-size speed and peak memory, all models
|
| 66 |
+
|
| 67 |
+
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|
| 68 |
+
| --- | --- | --- | --- | --- | --- |
|
| 69 |
+
| `patchmatchnet` | portable | 43.1 ms / 439 / 522 | 154.4 ms / 1242 / 1534 | 408.6 ms / 2753 / 3346 | OOM |
|
| 70 |
+
| `patchmatchnet` | kernels | 9.2 ms / 253 / 328 | 24.4 ms / 693 / 942 | 56.7 ms / 1520 / 2016 | 378.6 ms / 8628 / 11332 |
|
| 71 |
+
|
| 72 |
+
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
|
| 73 |
+
|
| 74 |
+
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.
|
| 75 |
+
|
| 76 |
+
## Accuracy
|
| 77 |
+
|
| 78 |
+
### Parity with the original code
|
| 79 |
+
|
| 80 |
+
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.5 % and p99 <= 3 % of the reference's median |value|.
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
from fastforks import multiview
|
| 86 |
+
|
| 87 |
+
model = multiview.load("patchmatchnet") # portable PyTorch on the GPU if there is one, else the CPU
|
| 88 |
+
result = model(["view0.jpg", "view1.jpg", "view2.jpg"]) # the views of one scene
|
| 89 |
+
result.depth # [V, H, W] float32 tensor; result.kind says what the maps mean
|
| 90 |
+
# calibrated MVS: model(views, intrinsics=K, cam_to_world=c2w), K [N, 3, 3], c2w [N, 4, 4]
|
| 91 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `patchmatchnet`.
|
| 95 |
+
|
| 96 |
+
## Kernels backend
|
| 97 |
+
|
| 98 |
+
`multiview.load("patchmatchnet", mode="kernels")` runs our CUDA kernels (`patchmatchnet`). 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.
|