depth-estimation 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {depth_estimation-0.1.2/src/depth_estimation.egg-info → depth_estimation-0.2.0}/PKG-INFO +47 -13
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/README.md +38 -8
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/pyproject.toml +15 -5
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/__init__.py +2 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/evaluation/evaluate.py +1 -1
- depth_estimation-0.2.0/src/depth_estimation/models/depth_pro_2/__init__.py +29 -0
- depth_estimation-0.2.0/src/depth_estimation/models/depth_pro_2/configuration_depth_pro_2.py +124 -0
- depth_estimation-0.2.0/src/depth_estimation/models/depth_pro_2/modeling_depth_pro_2.py +662 -0
- depth_estimation-0.2.0/src/depth_estimation/models/marigold_v2/__init__.py +29 -0
- depth_estimation-0.2.0/src/depth_estimation/models/marigold_v2/configuration_marigold_v2.py +92 -0
- depth_estimation-0.2.0/src/depth_estimation/models/marigold_v2/modeling_marigold_v2.py +452 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/processing_utils.py +3 -1
- {depth_estimation-0.1.2 → depth_estimation-0.2.0/src/depth_estimation.egg-info}/PKG-INFO +47 -13
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation.egg-info/SOURCES.txt +7 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation.egg-info/requires.txt +9 -4
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_auto.py +11 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_config.py +66 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_inference_all_models.py +63 -0
- depth_estimation-0.2.0/tests/test_marigold_v2_loading.py +57 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_processor.py +10 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/LICENSE +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/setup.cfg +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/cli.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/configuration_utils.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/base_dataset.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/diode.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/folder.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/hub.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/kitti.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/nyu_depth_v2.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/data/transforms.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/evaluation/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/evaluation/metrics.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/evaluation/profiling.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/export.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/losses.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/modeling_utils.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/auto/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/auto/modeling_auto.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/auto/processing_auto.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v1/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v1/configuration_depth_anything_v1.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v1/modeling_depth_anything_v1.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v2/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v2/configuration_depth_anything_v2.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v2/modeling_depth_anything_v2.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v3/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v3/configuration_depth_anything_v3.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_anything_v3/modeling_depth_anything_v3.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_pro/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_pro/configuration_depth_pro.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/depth_pro/modeling_depth_pro.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/marigold_dc/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/marigold_dc/configuration_marigold_dc.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/marigold_dc/modeling_marigold_dc.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/midas/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/midas/configuration_midas.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/midas/modeling_midas.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/moge/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/moge/configuration_moge.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/moge/modeling_moge.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/omnivggt/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/omnivggt/configuration_omnivggt.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/omnivggt/modeling_omnivggt.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/pixel_perfect_depth/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/pixel_perfect_depth/configuration_ppd.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/pixel_perfect_depth/modeling_ppd.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/vggt/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/vggt/configuration_vggt.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/vggt/modeling_vggt.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/zoedepth/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/zoedepth/configuration_zoedepth.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/models/zoedepth/modeling_zoedepth.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/output.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/pipeline_utils.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/pipelines/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/pipelines/depth_estimation.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/pruning.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/quantization.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/registry.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/trainer.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/training_args.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/video.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/viz/__init__.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/viz/animate.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/viz/composite.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/viz/display.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/viz/error.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation.egg-info/dependency_links.txt +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation.egg-info/entry_points.txt +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation.egg-info/top_level.txt +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_cli.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_data.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_evaluation.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_export_onnx.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_inference_image.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_losses.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_model.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_package.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_pipeline.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_pruning.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_quantization.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_training.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_transforms.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_video.py +0 -0
- {depth_estimation-0.1.2 → depth_estimation-0.2.0}/tests/test_viz.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: depth_estimation
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A Transformers-style Python library for monocular depth estimation — inference, evaluation, and fine-tuning
|
|
5
5
|
Author: shriarul5273
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,17 +20,19 @@ Classifier: Intended Audience :: Science/Research
|
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: torch>=2.
|
|
24
|
-
Requires-Dist: torchvision>=0.
|
|
23
|
+
Requires-Dist: torch>=2.6
|
|
24
|
+
Requires-Dist: torchvision>=0.21
|
|
25
25
|
Requires-Dist: Pillow>=9.0
|
|
26
26
|
Requires-Dist: numpy>=1.24
|
|
27
27
|
Requires-Dist: matplotlib>=3.6
|
|
28
28
|
Requires-Dist: opencv-python>=4.8
|
|
29
29
|
Requires-Dist: huggingface-hub>=0.16
|
|
30
30
|
Requires-Dist: transformers
|
|
31
|
-
Requires-Dist: diffusers
|
|
31
|
+
Requires-Dist: diffusers>=0.38
|
|
32
32
|
Requires-Dist: accelerate
|
|
33
|
-
Requires-Dist:
|
|
33
|
+
Requires-Dist: peft
|
|
34
|
+
Requires-Dist: safetensors
|
|
35
|
+
Requires-Dist: timm>=1.0.20
|
|
34
36
|
Requires-Dist: einops>=0.6
|
|
35
37
|
Requires-Dist: addict
|
|
36
38
|
Requires-Dist: h5py
|
|
@@ -43,6 +45,8 @@ Requires-Dist: onnxruntime; extra == "dev"
|
|
|
43
45
|
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
44
46
|
Provides-Extra: export
|
|
45
47
|
Requires-Dist: onnx>=1.14; extra == "export"
|
|
48
|
+
Provides-Extra: 4bit
|
|
49
|
+
Requires-Dist: bitsandbytes; extra == "4bit"
|
|
46
50
|
Dynamic: license-file
|
|
47
51
|
|
|
48
52
|
# depth_estimation
|
|
@@ -58,21 +62,44 @@ Dynamic: license-file
|
|
|
58
62
|
|
|
59
63
|
<h3 align="center">A unified Python library for monocular depth estimation</h3>
|
|
60
64
|
|
|
61
|
-
<h3 align="center">Inference · Video
|
|
65
|
+
<h3 align="center">Inference · Video · Training · Evaluation · ONNX Export · Pruning · Quantization</h3>
|
|
62
66
|
|
|
63
67
|
---
|
|
64
68
|
|
|
65
|
-
`depth_estimation` is
|
|
69
|
+
`depth_estimation` is a unified model framework for monocular depth estimation. It provides one consistent API across **14 model families and 36 variants**, so you can swap models, compare them, fine-tune them, and prepare them for deployment without rewriting your pipeline.
|
|
66
70
|
|
|
67
|
-
It covers the
|
|
71
|
+
It covers the workflow end-to-end: run inference with one line, process video, visualize results, evaluate standard benchmarks, fine-tune on custom depth data, optimize models, and export them to ONNX.
|
|
72
|
+
|
|
73
|
+
> **Latest release: v0.2.0 — Depth Pro 2, Marigold V2 & Dependency Fixes.** It adds Apple Depth Pro 2 and Marigold V2, and raises the minimum versions (PyTorch 2.6+) so a plain install runs every model. Read the [release notes](https://github.com/shriarul5273/depth_estimation/blob/main/docs/release_notes.md) or view the [GitHub release](https://github.com/shriarul5273/depth_estimation/releases/tag/v0.2.0).
|
|
68
74
|
|
|
69
75
|
## Installation
|
|
70
76
|
|
|
71
77
|
```bash
|
|
72
|
-
|
|
78
|
+
# Core library
|
|
79
|
+
pip install --upgrade depth-estimation
|
|
80
|
+
|
|
81
|
+
# ONNX export
|
|
82
|
+
pip install "depth-estimation[export]"
|
|
83
|
+
|
|
84
|
+
# Export verification and ONNX quantization
|
|
85
|
+
pip install "depth-estimation[export]" onnxruntime
|
|
86
|
+
|
|
87
|
+
# Optional: 4-bit Marigold V2 on CUDA (bitsandbytes)
|
|
88
|
+
pip install "depth-estimation[4bit]"
|
|
73
89
|
```
|
|
74
90
|
|
|
75
|
-
See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for
|
|
91
|
+
Python 3.10–3.12 and PyTorch 2.6+ are supported; the core install includes everything needed to run every model. For GPU execution of exported models, replace `onnxruntime` with `onnxruntime-gpu`. See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for the complete dependency guide.
|
|
92
|
+
|
|
93
|
+
## Documentation
|
|
94
|
+
|
|
95
|
+
| Goal | Guide |
|
|
96
|
+
|---|---|
|
|
97
|
+
| Choose a model | [Models](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) |
|
|
98
|
+
| Run video or visualize results | [Video](https://github.com/shriarul5273/depth_estimation/blob/main/docs/video.md) · [Visualization](https://github.com/shriarul5273/depth_estimation/blob/main/docs/viz.md) |
|
|
99
|
+
| Load data, evaluate, or fine-tune | [Data](https://github.com/shriarul5273/depth_estimation/blob/main/docs/data.md) · [Evaluation](https://github.com/shriarul5273/depth_estimation/blob/main/docs/evaluation.md) · [Training](https://github.com/shriarul5273/depth_estimation/blob/main/docs/training.md) |
|
|
100
|
+
| Prepare a model for deployment | [ONNX export](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) · [Pruning](https://github.com/shriarul5273/depth_estimation/blob/main/docs/pruning.md) · [Quantization](https://github.com/shriarul5273/depth_estimation/blob/main/docs/quantization.md) |
|
|
101
|
+
| Use the command line | [CLI reference](https://github.com/shriarul5273/depth_estimation/blob/main/docs/cli.md) |
|
|
102
|
+
| Extend the library | [Adding a model](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) |
|
|
76
103
|
|
|
77
104
|
---
|
|
78
105
|
|
|
@@ -119,7 +146,7 @@ depth-estimate predict image.jpg --model depth-anything-v2-vitb
|
|
|
119
146
|
Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
|
|
120
147
|
|
|
121
148
|
**2. The full depth workflow in one place.**
|
|
122
|
-
Most libraries stop at inference. This one covers training, evaluation
|
|
149
|
+
Most libraries stop at inference. This one also covers video, training, benchmark evaluation, dataset loading, pruning, quantization, and ONNX export, so you don't have to stitch together separate tools.
|
|
123
150
|
|
|
124
151
|
**3. Modular, single-file model design.**
|
|
125
152
|
Each model lives in one self-contained file. No hidden abstractions. If you need to understand or modify a model, there's exactly one place to look. New models self-register — `AutoDepthModel` and `pipeline()` resolve them automatically.
|
|
@@ -127,11 +154,14 @@ Each model lives in one self-contained file. No hidden abstractions. If you need
|
|
|
127
154
|
**4. Designed for research.**
|
|
128
155
|
Trainable models with backbone freeze schedules, proper batch-level metric accumulation (no mean-of-means), and a `compare()` function that shows a formatted table across models.
|
|
129
156
|
|
|
157
|
+
**5. Built for reliable deployment.**
|
|
158
|
+
Export verification checks ONNX output against PyTorch, quantization verifies accuracy by default, and unsupported model paths fail early with actionable errors.
|
|
159
|
+
|
|
130
160
|
---
|
|
131
161
|
|
|
132
162
|
## Supported Models
|
|
133
163
|
|
|
134
|
-
|
|
164
|
+
14 model families · 36 variants — see [docs/models.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) for the full list.
|
|
135
165
|
|
|
136
166
|
All models support inference and CLI. The Trainable column indicates fine-tuning support via `DepthTrainer`.
|
|
137
167
|
|
|
@@ -144,8 +174,10 @@ All models support inference and CLI. The Trainable column indicates fine-tuning
|
|
|
144
174
|
| ZoeDepth | nyu / kitti | Metric | ❌ |
|
|
145
175
|
| MiDaS | dpt-large / dpt-hybrid / beit-large | Relative | ✅ |
|
|
146
176
|
| Apple DepthPro | — | Metric | ✅ |
|
|
177
|
+
| Apple Depth Pro 2 | s / b / l / h | Metric | ✅ |
|
|
147
178
|
| Pixel-Perfect Depth | — | Relative | ❌ |
|
|
148
179
|
| Marigold-DC | — | Relative (depth completion) | ❌ |
|
|
180
|
+
| Marigold V2 | log / log-layered / uniform / disparity | Relative | ❌ |
|
|
149
181
|
| MoGe | v1 vitl / v2 vitl / v2 vitb / v2 vits (+ normal variants) | Metric | ❌ |
|
|
150
182
|
| OmniVGGT | vitl | Metric | ✅ |
|
|
151
183
|
| VGGT | standard / commercial | Metric | ✅ |
|
|
@@ -320,7 +352,7 @@ export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
|
|
|
320
352
|
depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
|
|
321
353
|
```
|
|
322
354
|
|
|
323
|
-
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge
|
|
355
|
+
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge`, with model-specific limitations documented in the compatibility table. `zoedepth` and `marigold-dc` are **not exportable** because both wrap opaque external pipelines; `export_onnx()` fails early with a clear error. Export requires `pip install "depth-estimation[export]"`; using `verify=True` additionally requires `onnxruntime` or `onnxruntime-gpu`. See [docs/export.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) for the full supported-models table and GPU setup.
|
|
324
356
|
|
|
325
357
|
</details>
|
|
326
358
|
|
|
@@ -339,6 +371,8 @@ model.export_onnx("pruned.onnx", verify=True) # pruned models export like any o
|
|
|
339
371
|
|
|
340
372
|
Pure PyTorch (`torch.nn.utils.prune`) — no special hardware or SDK. See [docs/pruning.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/pruning.md) for prune-aware fine-tuning and what pruning does/doesn't buy you (it zeros weights, it doesn't shrink tensors).
|
|
341
373
|
|
|
374
|
+
For a complete prune → fine-tune → export → quantize workflow, see [`examples/optimize.py`](https://github.com/shriarul5273/depth_estimation/blob/main/examples/optimize.py).
|
|
375
|
+
|
|
342
376
|
</details>
|
|
343
377
|
|
|
344
378
|
<details>
|
|
@@ -11,21 +11,44 @@
|
|
|
11
11
|
|
|
12
12
|
<h3 align="center">A unified Python library for monocular depth estimation</h3>
|
|
13
13
|
|
|
14
|
-
<h3 align="center">Inference · Video
|
|
14
|
+
<h3 align="center">Inference · Video · Training · Evaluation · ONNX Export · Pruning · Quantization</h3>
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
`depth_estimation` is
|
|
18
|
+
`depth_estimation` is a unified model framework for monocular depth estimation. It provides one consistent API across **14 model families and 36 variants**, so you can swap models, compare them, fine-tune them, and prepare them for deployment without rewriting your pipeline.
|
|
19
19
|
|
|
20
|
-
It covers the
|
|
20
|
+
It covers the workflow end-to-end: run inference with one line, process video, visualize results, evaluate standard benchmarks, fine-tune on custom depth data, optimize models, and export them to ONNX.
|
|
21
|
+
|
|
22
|
+
> **Latest release: v0.2.0 — Depth Pro 2, Marigold V2 & Dependency Fixes.** It adds Apple Depth Pro 2 and Marigold V2, and raises the minimum versions (PyTorch 2.6+) so a plain install runs every model. Read the [release notes](https://github.com/shriarul5273/depth_estimation/blob/main/docs/release_notes.md) or view the [GitHub release](https://github.com/shriarul5273/depth_estimation/releases/tag/v0.2.0).
|
|
21
23
|
|
|
22
24
|
## Installation
|
|
23
25
|
|
|
24
26
|
```bash
|
|
25
|
-
|
|
27
|
+
# Core library
|
|
28
|
+
pip install --upgrade depth-estimation
|
|
29
|
+
|
|
30
|
+
# ONNX export
|
|
31
|
+
pip install "depth-estimation[export]"
|
|
32
|
+
|
|
33
|
+
# Export verification and ONNX quantization
|
|
34
|
+
pip install "depth-estimation[export]" onnxruntime
|
|
35
|
+
|
|
36
|
+
# Optional: 4-bit Marigold V2 on CUDA (bitsandbytes)
|
|
37
|
+
pip install "depth-estimation[4bit]"
|
|
26
38
|
```
|
|
27
39
|
|
|
28
|
-
See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for
|
|
40
|
+
Python 3.10–3.12 and PyTorch 2.6+ are supported; the core install includes everything needed to run every model. For GPU execution of exported models, replace `onnxruntime` with `onnxruntime-gpu`. See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for the complete dependency guide.
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
| Goal | Guide |
|
|
45
|
+
|---|---|
|
|
46
|
+
| Choose a model | [Models](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) |
|
|
47
|
+
| Run video or visualize results | [Video](https://github.com/shriarul5273/depth_estimation/blob/main/docs/video.md) · [Visualization](https://github.com/shriarul5273/depth_estimation/blob/main/docs/viz.md) |
|
|
48
|
+
| Load data, evaluate, or fine-tune | [Data](https://github.com/shriarul5273/depth_estimation/blob/main/docs/data.md) · [Evaluation](https://github.com/shriarul5273/depth_estimation/blob/main/docs/evaluation.md) · [Training](https://github.com/shriarul5273/depth_estimation/blob/main/docs/training.md) |
|
|
49
|
+
| Prepare a model for deployment | [ONNX export](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) · [Pruning](https://github.com/shriarul5273/depth_estimation/blob/main/docs/pruning.md) · [Quantization](https://github.com/shriarul5273/depth_estimation/blob/main/docs/quantization.md) |
|
|
50
|
+
| Use the command line | [CLI reference](https://github.com/shriarul5273/depth_estimation/blob/main/docs/cli.md) |
|
|
51
|
+
| Extend the library | [Adding a model](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) |
|
|
29
52
|
|
|
30
53
|
---
|
|
31
54
|
|
|
@@ -72,7 +95,7 @@ depth-estimate predict image.jpg --model depth-anything-v2-vitb
|
|
|
72
95
|
Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
|
|
73
96
|
|
|
74
97
|
**2. The full depth workflow in one place.**
|
|
75
|
-
Most libraries stop at inference. This one covers training, evaluation
|
|
98
|
+
Most libraries stop at inference. This one also covers video, training, benchmark evaluation, dataset loading, pruning, quantization, and ONNX export, so you don't have to stitch together separate tools.
|
|
76
99
|
|
|
77
100
|
**3. Modular, single-file model design.**
|
|
78
101
|
Each model lives in one self-contained file. No hidden abstractions. If you need to understand or modify a model, there's exactly one place to look. New models self-register — `AutoDepthModel` and `pipeline()` resolve them automatically.
|
|
@@ -80,11 +103,14 @@ Each model lives in one self-contained file. No hidden abstractions. If you need
|
|
|
80
103
|
**4. Designed for research.**
|
|
81
104
|
Trainable models with backbone freeze schedules, proper batch-level metric accumulation (no mean-of-means), and a `compare()` function that shows a formatted table across models.
|
|
82
105
|
|
|
106
|
+
**5. Built for reliable deployment.**
|
|
107
|
+
Export verification checks ONNX output against PyTorch, quantization verifies accuracy by default, and unsupported model paths fail early with actionable errors.
|
|
108
|
+
|
|
83
109
|
---
|
|
84
110
|
|
|
85
111
|
## Supported Models
|
|
86
112
|
|
|
87
|
-
|
|
113
|
+
14 model families · 36 variants — see [docs/models.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) for the full list.
|
|
88
114
|
|
|
89
115
|
All models support inference and CLI. The Trainable column indicates fine-tuning support via `DepthTrainer`.
|
|
90
116
|
|
|
@@ -97,8 +123,10 @@ All models support inference and CLI. The Trainable column indicates fine-tuning
|
|
|
97
123
|
| ZoeDepth | nyu / kitti | Metric | ❌ |
|
|
98
124
|
| MiDaS | dpt-large / dpt-hybrid / beit-large | Relative | ✅ |
|
|
99
125
|
| Apple DepthPro | — | Metric | ✅ |
|
|
126
|
+
| Apple Depth Pro 2 | s / b / l / h | Metric | ✅ |
|
|
100
127
|
| Pixel-Perfect Depth | — | Relative | ❌ |
|
|
101
128
|
| Marigold-DC | — | Relative (depth completion) | ❌ |
|
|
129
|
+
| Marigold V2 | log / log-layered / uniform / disparity | Relative | ❌ |
|
|
102
130
|
| MoGe | v1 vitl / v2 vitl / v2 vitb / v2 vits (+ normal variants) | Metric | ❌ |
|
|
103
131
|
| OmniVGGT | vitl | Metric | ✅ |
|
|
104
132
|
| VGGT | standard / commercial | Metric | ✅ |
|
|
@@ -273,7 +301,7 @@ export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
|
|
|
273
301
|
depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
|
|
274
302
|
```
|
|
275
303
|
|
|
276
|
-
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge
|
|
304
|
+
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge`, with model-specific limitations documented in the compatibility table. `zoedepth` and `marigold-dc` are **not exportable** because both wrap opaque external pipelines; `export_onnx()` fails early with a clear error. Export requires `pip install "depth-estimation[export]"`; using `verify=True` additionally requires `onnxruntime` or `onnxruntime-gpu`. See [docs/export.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) for the full supported-models table and GPU setup.
|
|
277
305
|
|
|
278
306
|
</details>
|
|
279
307
|
|
|
@@ -292,6 +320,8 @@ model.export_onnx("pruned.onnx", verify=True) # pruned models export like any o
|
|
|
292
320
|
|
|
293
321
|
Pure PyTorch (`torch.nn.utils.prune`) — no special hardware or SDK. See [docs/pruning.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/pruning.md) for prune-aware fine-tuning and what pruning does/doesn't buy you (it zeros weights, it doesn't shrink tensors).
|
|
294
322
|
|
|
323
|
+
For a complete prune → fine-tune → export → quantize workflow, see [`examples/optimize.py`](https://github.com/shriarul5273/depth_estimation/blob/main/examples/optimize.py).
|
|
324
|
+
|
|
295
325
|
</details>
|
|
296
326
|
|
|
297
327
|
<details>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "depth_estimation"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "shriarul5273" },
|
|
10
10
|
]
|
|
@@ -26,17 +26,22 @@ classifiers = [
|
|
|
26
26
|
]
|
|
27
27
|
keywords = ["depth-estimation", "monocular-depth", "computer-vision", "deep-learning", "pytorch", "fine-tuning", "training"]
|
|
28
28
|
dependencies = [
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
# 2.6 is the oldest torch that current transformers and diffusers accept
|
|
30
|
+
# (they disable or fail to import torch below it), so it is the real
|
|
31
|
+
# floor for ZoeDepth, MiDaS, Marigold-DC and Marigold V2.
|
|
32
|
+
"torch>=2.6",
|
|
33
|
+
"torchvision>=0.21",
|
|
31
34
|
"Pillow>=9.0",
|
|
32
35
|
"numpy>=1.24",
|
|
33
36
|
"matplotlib>=3.6",
|
|
34
37
|
"opencv-python>=4.8",
|
|
35
38
|
"huggingface-hub>=0.16",
|
|
36
39
|
"transformers",
|
|
37
|
-
"diffusers",
|
|
40
|
+
"diffusers>=0.38",
|
|
38
41
|
"accelerate",
|
|
39
|
-
"
|
|
42
|
+
"peft",
|
|
43
|
+
"safetensors",
|
|
44
|
+
"timm>=1.0.20",
|
|
40
45
|
"einops>=0.6",
|
|
41
46
|
"addict",
|
|
42
47
|
"h5py",
|
|
@@ -59,6 +64,11 @@ dev = [
|
|
|
59
64
|
export = [
|
|
60
65
|
"onnx>=1.14",
|
|
61
66
|
]
|
|
67
|
+
# Optional 4-bit (NF4) loading of Marigold V2's Qwen DiT on CUDA; without it
|
|
68
|
+
# the model falls back to bfloat16. bitsandbytes itself needs torch>=2.4.
|
|
69
|
+
4bit = [
|
|
70
|
+
"bitsandbytes",
|
|
71
|
+
]
|
|
62
72
|
|
|
63
73
|
[project.scripts]
|
|
64
74
|
depth-estimate = "depth_estimation.cli:main"
|
|
@@ -20,8 +20,10 @@ from .models import depth_anything_v3
|
|
|
20
20
|
from .models import zoedepth
|
|
21
21
|
from .models import midas
|
|
22
22
|
from .models import depth_pro
|
|
23
|
+
from .models import depth_pro_2
|
|
23
24
|
from .models import pixel_perfect_depth
|
|
24
25
|
from .models import marigold_dc
|
|
26
|
+
from .models import marigold_v2
|
|
25
27
|
from .models import moge
|
|
26
28
|
from .models import omnivggt
|
|
27
29
|
from .models import vggt
|
{depth_estimation-0.1.2 → depth_estimation-0.2.0}/src/depth_estimation/evaluation/evaluate.py
RENAMED
|
@@ -226,7 +226,7 @@ def evaluate(
|
|
|
226
226
|
|
|
227
227
|
# Resize prediction to GT resolution
|
|
228
228
|
pred_resized = F.interpolate(
|
|
229
|
-
raw_preds[b].unsqueeze(0).unsqueeze(0),
|
|
229
|
+
raw_preds[b].float().unsqueeze(0).unsqueeze(0),
|
|
230
230
|
size=(oh, ow),
|
|
231
231
|
mode="bilinear",
|
|
232
232
|
align_corners=False,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Apple Depth Pro 2 model package — self-registers with MODEL_REGISTRY."""
|
|
2
|
+
|
|
3
|
+
from .configuration_depth_pro_2 import DepthPro2Config, _DEPTHPRO2_VARIANT_MAP
|
|
4
|
+
from ...registry import MODEL_REGISTRY
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _load_model_cls():
|
|
8
|
+
from .modeling_depth_pro_2 import DepthPro2Model
|
|
9
|
+
|
|
10
|
+
return DepthPro2Model
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
MODEL_REGISTRY.register(
|
|
14
|
+
model_type="depth-pro-2",
|
|
15
|
+
config_cls=DepthPro2Config,
|
|
16
|
+
model_cls=_load_model_cls,
|
|
17
|
+
variant_ids=list(_DEPTHPRO2_VARIANT_MAP.keys()),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __getattr__(name):
|
|
22
|
+
if name == "DepthPro2Model":
|
|
23
|
+
from .modeling_depth_pro_2 import DepthPro2Model
|
|
24
|
+
|
|
25
|
+
return DepthPro2Model
|
|
26
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
__all__ = ["DepthPro2Config", "DepthPro2Model"]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Apple Depth Pro 2 configuration.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import List, Optional
|
|
6
|
+
|
|
7
|
+
from ...configuration_utils import BaseDepthConfig
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Architecture presets, mirroring the ``config.json`` shipped in each
|
|
11
|
+
# ``apple/DepthPro2-*`` Hub repository (and ``PRESETS`` in ml-depth-pro-2).
|
|
12
|
+
_DEPTHPRO2_VARIANT_MAP = {
|
|
13
|
+
"depth-pro-2-s": {
|
|
14
|
+
"backbone": "vits",
|
|
15
|
+
"hub_repo_id": "apple/DepthPro2-S",
|
|
16
|
+
"backbone_preset": "vit_small_patch16_dinov3",
|
|
17
|
+
"reassembled_blocks": [2, 5, 8, 11],
|
|
18
|
+
"cross_frame_blocks": [5, 7, 9, 11],
|
|
19
|
+
"dims_reassemble": [48, 96, 192, 384],
|
|
20
|
+
"dim_decoder": 64,
|
|
21
|
+
},
|
|
22
|
+
"depth-pro-2-b": {
|
|
23
|
+
"backbone": "vitb",
|
|
24
|
+
"hub_repo_id": "apple/DepthPro2-B",
|
|
25
|
+
"backbone_preset": "vit_base_patch16_dinov3",
|
|
26
|
+
"reassembled_blocks": [2, 5, 8, 11],
|
|
27
|
+
"cross_frame_blocks": [5, 7, 9, 11],
|
|
28
|
+
"dims_reassemble": [96, 192, 384, 768],
|
|
29
|
+
"dim_decoder": 128,
|
|
30
|
+
},
|
|
31
|
+
"depth-pro-2-l": {
|
|
32
|
+
"backbone": "vitl",
|
|
33
|
+
"hub_repo_id": "apple/DepthPro2-L",
|
|
34
|
+
"backbone_preset": "vit_large_patch16_dinov3.lvd1689m",
|
|
35
|
+
"reassembled_blocks": [5, 11, 17, 23],
|
|
36
|
+
"cross_frame_blocks": [9, 11, 13, 15, 17, 19, 21, 23],
|
|
37
|
+
"dims_reassemble": [256, 512, 1024, 1024],
|
|
38
|
+
"dim_decoder": 256,
|
|
39
|
+
},
|
|
40
|
+
"depth-pro-2-h": {
|
|
41
|
+
"backbone": "vith+",
|
|
42
|
+
"hub_repo_id": "apple/DepthPro2-H",
|
|
43
|
+
"backbone_preset": "vit_huge_plus_patch16_dinov3",
|
|
44
|
+
"reassembled_blocks": [7, 15, 23, 31],
|
|
45
|
+
"cross_frame_blocks": [11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],
|
|
46
|
+
"dims_reassemble": [256, 512, 1024, 1024],
|
|
47
|
+
"dim_decoder": 256,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class DepthPro2Config(BaseDepthConfig):
|
|
53
|
+
"""Configuration for Apple Depth Pro 2.
|
|
54
|
+
|
|
55
|
+
Sharp, temporally consistent metric monocular depth. A DINOv3 multi-view
|
|
56
|
+
transformer feeds a DPT decoder that predicts focal-normalised inverse
|
|
57
|
+
depth; a separate DINOv3 ViT-S focal-length estimator
|
|
58
|
+
(``apple/DepthPro2-focal``) turns it into metric depth when the focal
|
|
59
|
+
length is unknown. Uses the bundled network implementation — no external
|
|
60
|
+
``depth_pro_2`` package needed.
|
|
61
|
+
|
|
62
|
+
The network runs at any resolution that is a multiple of 32, so
|
|
63
|
+
``patch_size`` is 32 here (the processor's resize multiple) even though
|
|
64
|
+
the ViT itself uses 16-pixel patches. ``input_size`` is the shorter side
|
|
65
|
+
the processor resizes to; raise it for sharper (slower) predictions.
|
|
66
|
+
|
|
67
|
+
``precision`` is the autocast dtype of the backbones and decoder:
|
|
68
|
+
``"auto"`` (bfloat16 on CUDA/MPS as trained, float32 on CPU),
|
|
69
|
+
``"float32"``, ``"bfloat16"`` or ``"float16"``. The heads always run in
|
|
70
|
+
float32.
|
|
71
|
+
|
|
72
|
+
``forward()`` returns 0 (invalid) where depth is infinite (sky) or beyond
|
|
73
|
+
``max_depth`` meters, like MoGe; ``model.infer()`` returns the raw
|
|
74
|
+
prediction with ``inf`` sky.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
model_type = "depth-pro-2"
|
|
78
|
+
|
|
79
|
+
def __init__(
|
|
80
|
+
self,
|
|
81
|
+
backbone: str = "vits",
|
|
82
|
+
input_size: int = 768,
|
|
83
|
+
patch_size: int = 32,
|
|
84
|
+
is_metric: bool = True,
|
|
85
|
+
hub_repo_id: str = "apple/DepthPro2-S",
|
|
86
|
+
hub_filename: str = "model.safetensors",
|
|
87
|
+
fov_repo_id: Optional[str] = "apple/DepthPro2-focal",
|
|
88
|
+
use_fov: bool = True,
|
|
89
|
+
backbone_preset: str = "vit_small_patch16_dinov3",
|
|
90
|
+
reassembled_blocks: Optional[List[int]] = None,
|
|
91
|
+
cross_frame_blocks: Optional[List[int]] = None,
|
|
92
|
+
dims_reassemble: Optional[List[int]] = None,
|
|
93
|
+
dim_decoder: int = 64,
|
|
94
|
+
precision: str = "auto",
|
|
95
|
+
max_depth: Optional[float] = 1000.0,
|
|
96
|
+
**kwargs,
|
|
97
|
+
):
|
|
98
|
+
super().__init__(
|
|
99
|
+
backbone=backbone,
|
|
100
|
+
input_size=input_size,
|
|
101
|
+
patch_size=patch_size,
|
|
102
|
+
is_metric=is_metric,
|
|
103
|
+
max_depth=max_depth,
|
|
104
|
+
**kwargs,
|
|
105
|
+
)
|
|
106
|
+
self.hub_repo_id = hub_repo_id
|
|
107
|
+
self.hub_filename = hub_filename
|
|
108
|
+
self.fov_repo_id = fov_repo_id
|
|
109
|
+
self.use_fov = use_fov
|
|
110
|
+
self.backbone_preset = backbone_preset
|
|
111
|
+
self.reassembled_blocks = list(reassembled_blocks or [2, 5, 8, 11])
|
|
112
|
+
self.cross_frame_blocks = list(cross_frame_blocks or [5, 7, 9, 11])
|
|
113
|
+
self.dims_reassemble = list(dims_reassemble or [48, 96, 192, 384])
|
|
114
|
+
self.dim_decoder = dim_decoder
|
|
115
|
+
self.precision = precision
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def from_variant(cls, variant_id: str) -> "DepthPro2Config":
|
|
119
|
+
if variant_id not in _DEPTHPRO2_VARIANT_MAP:
|
|
120
|
+
raise ValueError(
|
|
121
|
+
f"Unknown Depth Pro 2 variant '{variant_id}'. "
|
|
122
|
+
f"Available: {list(_DEPTHPRO2_VARIANT_MAP.keys())}"
|
|
123
|
+
)
|
|
124
|
+
return cls(**_DEPTHPRO2_VARIANT_MAP[variant_id])
|