depth-estimation 0.0.7__tar.gz → 0.0.9__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.
Files changed (89) hide show
  1. depth_estimation-0.0.9/PKG-INFO +246 -0
  2. depth_estimation-0.0.9/README.md +203 -0
  3. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/pyproject.toml +5 -12
  4. depth_estimation-0.0.9/src/depth_estimation/__init__.py +112 -0
  5. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/cli.py +221 -11
  6. depth_estimation-0.0.9/src/depth_estimation/data/__init__.py +131 -0
  7. depth_estimation-0.0.9/src/depth_estimation/data/base_dataset.py +81 -0
  8. depth_estimation-0.0.9/src/depth_estimation/data/diode.py +203 -0
  9. depth_estimation-0.0.9/src/depth_estimation/data/folder.py +161 -0
  10. depth_estimation-0.0.9/src/depth_estimation/data/hub.py +84 -0
  11. depth_estimation-0.0.9/src/depth_estimation/data/kitti.py +221 -0
  12. depth_estimation-0.0.9/src/depth_estimation/data/nyu_depth_v2.py +174 -0
  13. depth_estimation-0.0.9/src/depth_estimation/data/transforms.py +386 -0
  14. depth_estimation-0.0.9/src/depth_estimation/evaluation/__init__.py +56 -0
  15. depth_estimation-0.0.9/src/depth_estimation/evaluation/evaluate.py +408 -0
  16. depth_estimation-0.0.9/src/depth_estimation/evaluation/metrics.py +302 -0
  17. depth_estimation-0.0.9/src/depth_estimation/evaluation/profiling.py +143 -0
  18. depth_estimation-0.0.9/src/depth_estimation/losses.py +245 -0
  19. depth_estimation-0.0.9/src/depth_estimation/modeling_utils.py +253 -0
  20. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v1/modeling_depth_anything_v1.py +4 -0
  21. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v2/modeling_depth_anything_v2.py +4 -0
  22. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v3/modeling_depth_anything_v3.py +4 -0
  23. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_pro/modeling_depth_pro.py +30 -0
  24. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/marigold_dc/modeling_marigold_dc.py +7 -0
  25. depth_estimation-0.0.9/src/depth_estimation/models/midas/modeling_midas.py +132 -0
  26. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/moge/modeling_moge.py +9 -0
  27. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/omnivggt/modeling_omnivggt.py +20 -0
  28. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/pixel_perfect_depth/modeling_ppd.py +8 -0
  29. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/vggt/modeling_vggt.py +20 -0
  30. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/zoedepth/modeling_zoedepth.py +7 -0
  31. depth_estimation-0.0.9/src/depth_estimation/trainer.py +458 -0
  32. depth_estimation-0.0.9/src/depth_estimation/training_args.py +178 -0
  33. depth_estimation-0.0.9/src/depth_estimation.egg-info/PKG-INFO +246 -0
  34. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation.egg-info/SOURCES.txt +21 -1
  35. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation.egg-info/requires.txt +2 -9
  36. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/tests/test_auto.py +30 -11
  37. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/tests/test_config.py +100 -0
  38. depth_estimation-0.0.9/tests/test_data.py +289 -0
  39. depth_estimation-0.0.9/tests/test_evaluation.py +290 -0
  40. depth_estimation-0.0.9/tests/test_losses.py +227 -0
  41. depth_estimation-0.0.9/tests/test_training.py +299 -0
  42. depth_estimation-0.0.9/tests/test_transforms.py +346 -0
  43. depth_estimation-0.0.7/PKG-INFO +0 -197
  44. depth_estimation-0.0.7/README.md +0 -150
  45. depth_estimation-0.0.7/src/depth_estimation/__init__.py +0 -63
  46. depth_estimation-0.0.7/src/depth_estimation/modeling_utils.py +0 -111
  47. depth_estimation-0.0.7/src/depth_estimation/models/midas/modeling_midas.py +0 -115
  48. depth_estimation-0.0.7/src/depth_estimation.egg-info/PKG-INFO +0 -197
  49. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/LICENSE +0 -0
  50. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/setup.cfg +0 -0
  51. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/configuration_utils.py +0 -0
  52. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/__init__.py +0 -0
  53. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/auto/__init__.py +0 -0
  54. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/auto/modeling_auto.py +0 -0
  55. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/auto/processing_auto.py +0 -0
  56. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v1/__init__.py +0 -0
  57. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v1/configuration_depth_anything_v1.py +0 -0
  58. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v2/__init__.py +0 -0
  59. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v2/configuration_depth_anything_v2.py +0 -0
  60. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v3/__init__.py +0 -0
  61. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_anything_v3/configuration_depth_anything_v3.py +0 -0
  62. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_pro/__init__.py +0 -0
  63. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/depth_pro/configuration_depth_pro.py +0 -0
  64. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/marigold_dc/__init__.py +0 -0
  65. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/marigold_dc/configuration_marigold_dc.py +0 -0
  66. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/midas/__init__.py +0 -0
  67. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/midas/configuration_midas.py +0 -0
  68. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/moge/__init__.py +0 -0
  69. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/moge/configuration_moge.py +0 -0
  70. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/omnivggt/__init__.py +0 -0
  71. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/omnivggt/configuration_omnivggt.py +0 -0
  72. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/pixel_perfect_depth/__init__.py +0 -0
  73. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/pixel_perfect_depth/configuration_ppd.py +0 -0
  74. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/vggt/__init__.py +0 -0
  75. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/vggt/configuration_vggt.py +0 -0
  76. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/zoedepth/__init__.py +0 -0
  77. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/models/zoedepth/configuration_zoedepth.py +0 -0
  78. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/output.py +0 -0
  79. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/pipeline_utils.py +0 -0
  80. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/pipelines/__init__.py +0 -0
  81. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/pipelines/depth_estimation.py +0 -0
  82. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/processing_utils.py +0 -0
  83. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation/registry.py +0 -0
  84. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation.egg-info/dependency_links.txt +0 -0
  85. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation.egg-info/entry_points.txt +0 -0
  86. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/src/depth_estimation.egg-info/top_level.txt +0 -0
  87. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/tests/test_model.py +0 -0
  88. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/tests/test_pipeline.py +0 -0
  89. {depth_estimation-0.0.7 → depth_estimation-0.0.9}/tests/test_processor.py +0 -0
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: depth_estimation
3
+ Version: 0.0.9
4
+ Summary: A Transformers-style Python library for monocular depth estimation — inference, evaluation, and fine-tuning
5
+ Author: shriarul5273
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/shriarul5273/depth_estimation
8
+ Project-URL: Repository, https://github.com/shriarul5273/depth_estimation
9
+ Project-URL: Issues, https://github.com/shriarul5273/depth_estimation/issues
10
+ Keywords: depth-estimation,monocular-depth,computer-vision,deep-learning,pytorch,fine-tuning,training
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Science/Research
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: torch==2.10.0
25
+ Requires-Dist: torchvision>=0.15
26
+ Requires-Dist: Pillow>=9.0
27
+ Requires-Dist: numpy>=1.24
28
+ Requires-Dist: matplotlib>=3.6
29
+ Requires-Dist: opencv-python>=4.8
30
+ Requires-Dist: huggingface-hub>=0.16
31
+ Requires-Dist: transformers
32
+ Requires-Dist: diffusers
33
+ Requires-Dist: accelerate
34
+ Requires-Dist: timm>=0.9.1
35
+ Requires-Dist: einops>=0.6
36
+ Requires-Dist: addict
37
+ Requires-Dist: h5py
38
+ Requires-Dist: tqdm
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=7.0; extra == "dev"
41
+ Requires-Dist: pytest-cov; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # depth_estimation
45
+
46
+ <p align="center">
47
+ <a href="https://github.com/shriarul5273/depth_estimation/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/shriarul5273/depth_estimation?color=blue"></a>
48
+ <a href="https://pypi.org/project/depth-estimation/"><img alt="PyPI" src="https://img.shields.io/pypi/v/depth-estimation"></a>
49
+ <a href="https://pypi.org/project/depth-estimation/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/depth-estimation"></a>
50
+ </p>
51
+
52
+ <h3 align="center">A unified Python library for monocular depth estimation</h3>
53
+
54
+ <h3 align="center">Inference · Fine-Tuning · Evaluation · Dataset Loading</h3>
55
+
56
+ ---
57
+
58
+ `depth_estimation` is the model-definition framework for depth estimation. It provides a single, consistent API across **12 model families and 28 variants** — so you can swap models, compare them, and fine-tune them without rewriting your pipeline.
59
+
60
+ It covers the full workflow end-to-end: run inference with one line, evaluate on standard benchmarks, and fine-tune on custom depth data — all with the same library.
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install depth-estimation
66
+ ```
67
+
68
+ See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for optional extras (CUDA, MPS, etc.).
69
+
70
+ ---
71
+
72
+ ## Quickstart
73
+
74
+ The `pipeline` API is the fastest way to get a depth map from any image:
75
+
76
+ ```python
77
+ from depth_estimation import pipeline
78
+
79
+ pipe = pipeline("depth-estimation", model="depth-anything-v2-vitb")
80
+ result = pipe("image.jpg")
81
+
82
+ depth_map = result.depth # np.ndarray, float32, (H, W)
83
+ colored = result.colored_depth # np.ndarray, uint8, (H, W, 3)
84
+ ```
85
+
86
+ For full control over each step — preprocessing, forward pass, postprocessing — use Auto Classes:
87
+
88
+ ```python
89
+ from depth_estimation import AutoDepthModel, AutoProcessor
90
+ import torch
91
+
92
+ model = AutoDepthModel.from_pretrained("zoedepth")
93
+ processor = AutoProcessor.from_pretrained("zoedepth")
94
+
95
+ inputs = processor("image.jpg")
96
+ with torch.no_grad():
97
+ depth = model(inputs["pixel_values"])
98
+ result = processor.postprocess(depth, inputs["original_sizes"])
99
+ ```
100
+
101
+ Or from the command line:
102
+
103
+ ```bash
104
+ depth-estimate predict image.jpg --model depth-anything-v2-vitb
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Why use depth_estimation?
110
+
111
+ **1. One API, every model.**
112
+ Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
113
+
114
+ **2. The full depth workflow in one place.**
115
+ Most libraries stop at inference. This one covers training, evaluation on standard benchmarks, and dataset loading — so you don't have to stitch together separate tools.
116
+
117
+ **3. Modular, single-file model design.**
118
+ 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.
119
+
120
+ **4. Designed for research.**
121
+ 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.
122
+
123
+ ---
124
+
125
+ ## Supported Models
126
+
127
+ 12 model families · 28 variants — see [docs/models.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) for the full list.
128
+
129
+ All models support inference and CLI. The Trainable column indicates fine-tuning support via `DepthTrainer`.
130
+
131
+ | Family | Variants | Depth type | Trainable |
132
+ |---|---|---|:---:|
133
+ | Depth Anything v1 | vits / vitb / vitl | Relative | ✅ |
134
+ | Depth Anything v2 | vits / vitb / vitl | Relative | ✅ |
135
+ | Depth Anything v3 | small / base / large / giant / mono / metric | Relative + Metric | ✅ |
136
+ | Depth Anything v3 Nested | nested-giant-large | Relative | ✅ |
137
+ | ZoeDepth | nyu / kitti | Metric | ❌ |
138
+ | MiDaS | dpt-large / dpt-hybrid / beit-large | Relative | ✅ |
139
+ | Apple DepthPro | — | Metric | ✅ |
140
+ | Pixel-Perfect Depth | — | Relative | ❌ |
141
+ | Marigold-DC | — | Relative (depth completion) | ❌ |
142
+ | MoGe | v1 vitl / v2 vitl / v2 vitb / v2 vits (+ normal variants) | Metric | ❌ |
143
+ | OmniVGGT | vitl | Metric | ✅ |
144
+ | VGGT | standard / commercial | Metric | ✅ |
145
+
146
+ ---
147
+
148
+ ## What can you do?
149
+
150
+ <details>
151
+ <summary><b>Inference</b> — single image, batch, or video</summary>
152
+
153
+ ```python
154
+ # Single image
155
+ result = pipe("image.jpg")
156
+
157
+ # Batch
158
+ results = pipe(["img1.jpg", "img2.jpg"], batch_size=2)
159
+ ```
160
+
161
+ ```bash
162
+ # CLI — batch predict
163
+ depth-estimate predict "images/*.jpg" --model depth-anything-v2-vitb --output-dir results/
164
+ ```
165
+
166
+ </details>
167
+
168
+ <details>
169
+ <summary><b>Evaluation</b> — standard benchmarks, custom predictions</summary>
170
+
171
+ ```python
172
+ from depth_estimation.evaluation import evaluate, compare, Evaluator
173
+
174
+ # Single model on NYU Depth V2
175
+ results = evaluate("depth-anything-v2-vitb", "nyu_depth_v2", split="test")
176
+
177
+ # Compare multiple models — prints table with best values marked (*)
178
+ compare(["depth-anything-v2-vits", "depth-anything-v2-vitb"], dataset="nyu_depth_v2")
179
+
180
+ # Accumulate metrics over your own dataloader
181
+ ev = Evaluator()
182
+ for pred, gt, mask in dataloader:
183
+ ev.update(pred, gt, mask)
184
+ final = ev.compute() # abs_rel, sq_rel, rmse, rmse_log, delta1/2/3
185
+ ```
186
+
187
+ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/evaluation.md).
188
+
189
+ </details>
190
+
191
+ <details>
192
+ <summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
193
+
194
+ ```python
195
+ from depth_estimation import DepthAnythingV2Model, DepthTrainer, DepthTrainingArguments, load_dataset
196
+ from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
197
+
198
+ model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
199
+ train_ds = load_dataset("nyu_depth_v2", split="train", transform=get_train_transforms(518))
200
+ val_ds = load_dataset("nyu_depth_v2", split="test", transform=get_val_transforms(518))
201
+
202
+ args = DepthTrainingArguments(output_dir="./checkpoints", num_epochs=25, batch_size=8,
203
+ freeze_backbone_epochs=5, mixed_precision=True)
204
+ DepthTrainer(model=model, args=args, train_dataset=train_ds, eval_dataset=val_ds).train()
205
+ ```
206
+
207
+ Any `torch.utils.data.Dataset` returning `pixel_values / depth_map / valid_mask` works directly — no subclassing needed. See [docs/training.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/training.md).
208
+
209
+ </details>
210
+
211
+ <details>
212
+ <summary><b>Dataset Loading</b> — standard benchmarks, custom folders</summary>
213
+
214
+ ```python
215
+ from depth_estimation import load_dataset
216
+
217
+ ds = load_dataset("nyu_depth_v2", split="test") # auto-downloads ~2.8 GB
218
+ ds = load_dataset("diode", split="val", scene_type="indoors") # auto-downloads ~2.6 GB
219
+ ds = load_dataset("kitti_eigen", split="test", root="/data/kitti") # local path
220
+ ds = load_dataset("folder", image_dir="rgb/", depth_dir="depth/") # any folder
221
+ ```
222
+
223
+ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/data.md).
224
+
225
+ </details>
226
+
227
+ ---
228
+
229
+ ## Adding a New Model
230
+
231
+ 1. Create `src/depth_estimation/models/your_model/`
232
+ 2. Add `configuration_your_model.py` (inherit `BaseDepthConfig`)
233
+ 3. Add `modeling_your_model.py` (inherit `BaseDepthModel`, single file)
234
+ 4. Add `__init__.py` with `MODEL_REGISTRY.register(...)`
235
+
236
+ `AutoDepthModel`, `AutoProcessor`, and `pipeline()` resolve the new model automatically. See [docs/adding_a_model.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) for a step-by-step guide.
237
+
238
+ ---
239
+
240
+ ## Acknowledgments
241
+
242
+ This library builds upon the work of 12 research teams — see [docs/models.md#citations](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md#citations) for the full list.
243
+
244
+ ## License
245
+
246
+ MIT
@@ -0,0 +1,203 @@
1
+ # depth_estimation
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/shriarul5273/depth_estimation/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/shriarul5273/depth_estimation?color=blue"></a>
5
+ <a href="https://pypi.org/project/depth-estimation/"><img alt="PyPI" src="https://img.shields.io/pypi/v/depth-estimation"></a>
6
+ <a href="https://pypi.org/project/depth-estimation/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/depth-estimation"></a>
7
+ </p>
8
+
9
+ <h3 align="center">A unified Python library for monocular depth estimation</h3>
10
+
11
+ <h3 align="center">Inference · Fine-Tuning · Evaluation · Dataset Loading</h3>
12
+
13
+ ---
14
+
15
+ `depth_estimation` is the model-definition framework for depth estimation. It provides a single, consistent API across **12 model families and 28 variants** — so you can swap models, compare them, and fine-tune them without rewriting your pipeline.
16
+
17
+ It covers the full workflow end-to-end: run inference with one line, evaluate on standard benchmarks, and fine-tune on custom depth data — all with the same library.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install depth-estimation
23
+ ```
24
+
25
+ See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for optional extras (CUDA, MPS, etc.).
26
+
27
+ ---
28
+
29
+ ## Quickstart
30
+
31
+ The `pipeline` API is the fastest way to get a depth map from any image:
32
+
33
+ ```python
34
+ from depth_estimation import pipeline
35
+
36
+ pipe = pipeline("depth-estimation", model="depth-anything-v2-vitb")
37
+ result = pipe("image.jpg")
38
+
39
+ depth_map = result.depth # np.ndarray, float32, (H, W)
40
+ colored = result.colored_depth # np.ndarray, uint8, (H, W, 3)
41
+ ```
42
+
43
+ For full control over each step — preprocessing, forward pass, postprocessing — use Auto Classes:
44
+
45
+ ```python
46
+ from depth_estimation import AutoDepthModel, AutoProcessor
47
+ import torch
48
+
49
+ model = AutoDepthModel.from_pretrained("zoedepth")
50
+ processor = AutoProcessor.from_pretrained("zoedepth")
51
+
52
+ inputs = processor("image.jpg")
53
+ with torch.no_grad():
54
+ depth = model(inputs["pixel_values"])
55
+ result = processor.postprocess(depth, inputs["original_sizes"])
56
+ ```
57
+
58
+ Or from the command line:
59
+
60
+ ```bash
61
+ depth-estimate predict image.jpg --model depth-anything-v2-vitb
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Why use depth_estimation?
67
+
68
+ **1. One API, every model.**
69
+ Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
70
+
71
+ **2. The full depth workflow in one place.**
72
+ Most libraries stop at inference. This one covers training, evaluation on standard benchmarks, and dataset loading — so you don't have to stitch together separate tools.
73
+
74
+ **3. Modular, single-file model design.**
75
+ 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.
76
+
77
+ **4. Designed for research.**
78
+ 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.
79
+
80
+ ---
81
+
82
+ ## Supported Models
83
+
84
+ 12 model families · 28 variants — see [docs/models.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) for the full list.
85
+
86
+ All models support inference and CLI. The Trainable column indicates fine-tuning support via `DepthTrainer`.
87
+
88
+ | Family | Variants | Depth type | Trainable |
89
+ |---|---|---|:---:|
90
+ | Depth Anything v1 | vits / vitb / vitl | Relative | ✅ |
91
+ | Depth Anything v2 | vits / vitb / vitl | Relative | ✅ |
92
+ | Depth Anything v3 | small / base / large / giant / mono / metric | Relative + Metric | ✅ |
93
+ | Depth Anything v3 Nested | nested-giant-large | Relative | ✅ |
94
+ | ZoeDepth | nyu / kitti | Metric | ❌ |
95
+ | MiDaS | dpt-large / dpt-hybrid / beit-large | Relative | ✅ |
96
+ | Apple DepthPro | — | Metric | ✅ |
97
+ | Pixel-Perfect Depth | — | Relative | ❌ |
98
+ | Marigold-DC | — | Relative (depth completion) | ❌ |
99
+ | MoGe | v1 vitl / v2 vitl / v2 vitb / v2 vits (+ normal variants) | Metric | ❌ |
100
+ | OmniVGGT | vitl | Metric | ✅ |
101
+ | VGGT | standard / commercial | Metric | ✅ |
102
+
103
+ ---
104
+
105
+ ## What can you do?
106
+
107
+ <details>
108
+ <summary><b>Inference</b> — single image, batch, or video</summary>
109
+
110
+ ```python
111
+ # Single image
112
+ result = pipe("image.jpg")
113
+
114
+ # Batch
115
+ results = pipe(["img1.jpg", "img2.jpg"], batch_size=2)
116
+ ```
117
+
118
+ ```bash
119
+ # CLI — batch predict
120
+ depth-estimate predict "images/*.jpg" --model depth-anything-v2-vitb --output-dir results/
121
+ ```
122
+
123
+ </details>
124
+
125
+ <details>
126
+ <summary><b>Evaluation</b> — standard benchmarks, custom predictions</summary>
127
+
128
+ ```python
129
+ from depth_estimation.evaluation import evaluate, compare, Evaluator
130
+
131
+ # Single model on NYU Depth V2
132
+ results = evaluate("depth-anything-v2-vitb", "nyu_depth_v2", split="test")
133
+
134
+ # Compare multiple models — prints table with best values marked (*)
135
+ compare(["depth-anything-v2-vits", "depth-anything-v2-vitb"], dataset="nyu_depth_v2")
136
+
137
+ # Accumulate metrics over your own dataloader
138
+ ev = Evaluator()
139
+ for pred, gt, mask in dataloader:
140
+ ev.update(pred, gt, mask)
141
+ final = ev.compute() # abs_rel, sq_rel, rmse, rmse_log, delta1/2/3
142
+ ```
143
+
144
+ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/evaluation.md).
145
+
146
+ </details>
147
+
148
+ <details>
149
+ <summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
150
+
151
+ ```python
152
+ from depth_estimation import DepthAnythingV2Model, DepthTrainer, DepthTrainingArguments, load_dataset
153
+ from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
154
+
155
+ model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
156
+ train_ds = load_dataset("nyu_depth_v2", split="train", transform=get_train_transforms(518))
157
+ val_ds = load_dataset("nyu_depth_v2", split="test", transform=get_val_transforms(518))
158
+
159
+ args = DepthTrainingArguments(output_dir="./checkpoints", num_epochs=25, batch_size=8,
160
+ freeze_backbone_epochs=5, mixed_precision=True)
161
+ DepthTrainer(model=model, args=args, train_dataset=train_ds, eval_dataset=val_ds).train()
162
+ ```
163
+
164
+ Any `torch.utils.data.Dataset` returning `pixel_values / depth_map / valid_mask` works directly — no subclassing needed. See [docs/training.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/training.md).
165
+
166
+ </details>
167
+
168
+ <details>
169
+ <summary><b>Dataset Loading</b> — standard benchmarks, custom folders</summary>
170
+
171
+ ```python
172
+ from depth_estimation import load_dataset
173
+
174
+ ds = load_dataset("nyu_depth_v2", split="test") # auto-downloads ~2.8 GB
175
+ ds = load_dataset("diode", split="val", scene_type="indoors") # auto-downloads ~2.6 GB
176
+ ds = load_dataset("kitti_eigen", split="test", root="/data/kitti") # local path
177
+ ds = load_dataset("folder", image_dir="rgb/", depth_dir="depth/") # any folder
178
+ ```
179
+
180
+ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/data.md).
181
+
182
+ </details>
183
+
184
+ ---
185
+
186
+ ## Adding a New Model
187
+
188
+ 1. Create `src/depth_estimation/models/your_model/`
189
+ 2. Add `configuration_your_model.py` (inherit `BaseDepthConfig`)
190
+ 3. Add `modeling_your_model.py` (inherit `BaseDepthModel`, single file)
191
+ 4. Add `__init__.py` with `MODEL_REGISTRY.register(...)`
192
+
193
+ `AutoDepthModel`, `AutoProcessor`, and `pipeline()` resolve the new model automatically. See [docs/adding_a_model.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) for a step-by-step guide.
194
+
195
+ ---
196
+
197
+ ## Acknowledgments
198
+
199
+ This library builds upon the work of 12 research teams — see [docs/models.md#citations](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md#citations) for the full list.
200
+
201
+ ## License
202
+
203
+ MIT
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "depth_estimation"
7
- version = "0.0.7"
7
+ version = "0.0.9"
8
8
  authors = [
9
9
  { name = "shriarul5273" },
10
10
  ]
11
- description = "A Transformers-style Python library for monocular depth estimation"
11
+ description = "A Transformers-style Python library for monocular depth estimation — inference, evaluation, and fine-tuning"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.9"
14
14
  license = "MIT"
@@ -25,7 +25,7 @@ classifiers = [
25
25
  "Intended Audience :: Developers",
26
26
  "Intended Audience :: Science/Research",
27
27
  ]
28
- keywords = ["depth-estimation", "monocular-depth", "computer-vision", "deep-learning", "pytorch"]
28
+ keywords = ["depth-estimation", "monocular-depth", "computer-vision", "deep-learning", "pytorch", "fine-tuning", "training"]
29
29
  dependencies = [
30
30
  "torch==2.10.0",
31
31
  "torchvision>=0.15",
@@ -40,6 +40,8 @@ dependencies = [
40
40
  "timm>=0.9.1",
41
41
  "einops>=0.6",
42
42
  "addict",
43
+ "h5py",
44
+ "tqdm"
43
45
  ]
44
46
 
45
47
  [project.urls]
@@ -52,15 +54,6 @@ dev = [
52
54
  "pytest>=7.0",
53
55
  "pytest-cov",
54
56
  ]
55
- transformers = [
56
- "transformers>=4.30",
57
- ]
58
- diffusers = [
59
- "diffusers>=0.25",
60
- ]
61
- all = [
62
- "depth_estimation[transformers,diffusers]",
63
- ]
64
57
 
65
58
  [project.scripts]
66
59
  depth-estimate = "depth_estimation.cli:main"
@@ -0,0 +1,112 @@
1
+ """
2
+ depth_estimation — A Transformers-style Python library for monocular depth estimation.
3
+
4
+ Provides a unified, modular API for running, comparing, and integrating
5
+ depth estimation models.
6
+ """
7
+
8
+ from .output import DepthOutput
9
+ from .configuration_utils import BaseDepthConfig
10
+ from .registry import MODEL_REGISTRY
11
+
12
+ # Auto classes
13
+ from .models.auto import AutoDepthModel, AutoProcessor
14
+
15
+ # Ensure model modules are imported so they self-register.
16
+ # These are now torch-free — modeling classes are loaded lazily on first use.
17
+ from .models import depth_anything_v1
18
+ from .models import depth_anything_v2
19
+ from .models import depth_anything_v3
20
+ from .models import zoedepth
21
+ from .models import midas
22
+ from .models import depth_pro
23
+ from .models import pixel_perfect_depth
24
+ from .models import marigold_dc
25
+ from .models import moge
26
+ from .models import omnivggt
27
+ from .models import vggt
28
+
29
+
30
+ def load_dataset(name, split="train", root=None, download=True, transform=None, **kwargs):
31
+ """Load a depth dataset by name. See :mod:`depth_estimation.data` for details."""
32
+ from .data import load_dataset as _load
33
+ return _load(name, split=split, root=root, download=download, transform=transform, **kwargs)
34
+
35
+
36
+ def __getattr__(name):
37
+ """Defer torch-heavy imports until first use."""
38
+ if name == "BaseDepthModel":
39
+ from .modeling_utils import BaseDepthModel
40
+ globals()["BaseDepthModel"] = BaseDepthModel
41
+ return BaseDepthModel
42
+ if name == "DepthProcessor":
43
+ from .processing_utils import DepthProcessor
44
+ globals()["DepthProcessor"] = DepthProcessor
45
+ return DepthProcessor
46
+ if name == "DepthPipeline":
47
+ from .pipeline_utils import DepthPipeline
48
+ globals()["DepthPipeline"] = DepthPipeline
49
+ return DepthPipeline
50
+ if name == "pipeline":
51
+ from .pipeline_utils import pipeline
52
+ globals()["pipeline"] = pipeline
53
+ return pipeline
54
+ # Training symbols
55
+ if name == "DepthTrainer":
56
+ from .trainer import DepthTrainer
57
+ globals()["DepthTrainer"] = DepthTrainer
58
+ return DepthTrainer
59
+ if name == "DepthTrainingArguments":
60
+ from .training_args import DepthTrainingArguments
61
+ globals()["DepthTrainingArguments"] = DepthTrainingArguments
62
+ return DepthTrainingArguments
63
+ if name == "CombinedDepthLoss":
64
+ from .losses import CombinedDepthLoss
65
+ globals()["CombinedDepthLoss"] = CombinedDepthLoss
66
+ return CombinedDepthLoss
67
+ if name == "ScaleInvariantLoss":
68
+ from .losses import ScaleInvariantLoss
69
+ globals()["ScaleInvariantLoss"] = ScaleInvariantLoss
70
+ return ScaleInvariantLoss
71
+ if name == "GradientLoss":
72
+ from .losses import GradientLoss
73
+ globals()["GradientLoss"] = GradientLoss
74
+ return GradientLoss
75
+ if name == "BerHuLoss":
76
+ from .losses import BerHuLoss
77
+ globals()["BerHuLoss"] = BerHuLoss
78
+ return BerHuLoss
79
+ if name == "get_train_transforms":
80
+ from .data.transforms import get_train_transforms
81
+ globals()["get_train_transforms"] = get_train_transforms
82
+ return get_train_transforms
83
+ if name == "get_val_transforms":
84
+ from .data.transforms import get_val_transforms
85
+ globals()["get_val_transforms"] = get_val_transforms
86
+ return get_val_transforms
87
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
88
+
89
+
90
+ __all__ = [
91
+ "DepthOutput",
92
+ "BaseDepthConfig",
93
+ "BaseDepthModel",
94
+ "DepthProcessor",
95
+ "DepthPipeline",
96
+ "pipeline",
97
+ "AutoDepthModel",
98
+ "AutoProcessor",
99
+ "MODEL_REGISTRY",
100
+ "load_dataset",
101
+ # Training
102
+ "DepthTrainer",
103
+ "DepthTrainingArguments",
104
+ "CombinedDepthLoss",
105
+ "ScaleInvariantLoss",
106
+ "GradientLoss",
107
+ "BerHuLoss",
108
+ "get_train_transforms",
109
+ "get_val_transforms",
110
+ ]
111
+
112
+ __version__ = "0.0.9"