depth-estimation 0.1.1__tar.gz → 0.1.3__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 (102) hide show
  1. {depth_estimation-0.1.1/src/depth_estimation.egg-info → depth_estimation-0.1.3}/PKG-INFO +96 -11
  2. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/README.md +88 -7
  3. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/pyproject.toml +35 -4
  4. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/__init__.py +72 -3
  5. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/cli.py +197 -42
  6. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/configuration_utils.py +2 -0
  7. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/__init__.py +4 -7
  8. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/base_dataset.py +1 -1
  9. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/diode.py +2 -4
  10. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/folder.py +5 -3
  11. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/hub.py +37 -3
  12. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/kitti.py +5 -8
  13. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/nyu_depth_v2.py +10 -14
  14. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/data/transforms.py +47 -30
  15. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/evaluation/evaluate.py +48 -33
  16. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/evaluation/metrics.py +71 -46
  17. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/evaluation/profiling.py +15 -13
  18. depth_estimation-0.1.3/src/depth_estimation/export.py +301 -0
  19. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/losses.py +6 -2
  20. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/modeling_utils.py +114 -4
  21. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/auto/processing_auto.py +2 -1
  22. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v1/__init__.py +2 -0
  23. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v1/configuration_depth_anything_v1.py +1 -1
  24. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v1/modeling_depth_anything_v1.py +173 -43
  25. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v2/__init__.py +2 -0
  26. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v2/configuration_depth_anything_v2.py +4 -2
  27. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v2/modeling_depth_anything_v2.py +397 -126
  28. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v3/__init__.py +4 -0
  29. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v3/configuration_depth_anything_v3.py +6 -6
  30. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_anything_v3/modeling_depth_anything_v3.py +257 -77
  31. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_pro/__init__.py +2 -0
  32. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_pro/modeling_depth_pro.py +79 -27
  33. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/marigold_dc/__init__.py +2 -0
  34. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/marigold_dc/modeling_marigold_dc.py +68 -30
  35. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/midas/__init__.py +2 -0
  36. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/midas/configuration_midas.py +14 -0
  37. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/midas/modeling_midas.py +3 -1
  38. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/moge/__init__.py +2 -0
  39. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/moge/modeling_moge.py +1136 -421
  40. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/omnivggt/__init__.py +2 -0
  41. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/omnivggt/modeling_omnivggt.py +861 -283
  42. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/pixel_perfect_depth/__init__.py +2 -0
  43. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/pixel_perfect_depth/modeling_ppd.py +76 -34
  44. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/vggt/__init__.py +2 -0
  45. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/vggt/modeling_vggt.py +663 -223
  46. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/zoedepth/__init__.py +2 -0
  47. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/zoedepth/modeling_zoedepth.py +20 -6
  48. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/pipeline_utils.py +20 -8
  49. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/processing_utils.py +24 -15
  50. depth_estimation-0.1.3/src/depth_estimation/pruning.py +216 -0
  51. depth_estimation-0.1.3/src/depth_estimation/quantization.py +284 -0
  52. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/registry.py +1 -1
  53. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/trainer.py +19 -11
  54. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/training_args.py +13 -6
  55. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/video.py +11 -8
  56. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/viz/animate.py +7 -2
  57. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/viz/composite.py +8 -3
  58. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/viz/display.py +8 -2
  59. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/viz/error.py +4 -4
  60. {depth_estimation-0.1.1 → depth_estimation-0.1.3/src/depth_estimation.egg-info}/PKG-INFO +96 -11
  61. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation.egg-info/SOURCES.txt +10 -0
  62. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation.egg-info/requires.txt +7 -1
  63. depth_estimation-0.1.3/tests/test_auto.py +174 -0
  64. depth_estimation-0.1.3/tests/test_cli.py +279 -0
  65. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_config.py +48 -26
  66. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_data.py +85 -4
  67. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_evaluation.py +15 -3
  68. depth_estimation-0.1.3/tests/test_export_onnx.py +402 -0
  69. depth_estimation-0.1.3/tests/test_inference_all_models.py +161 -0
  70. depth_estimation-0.1.3/tests/test_inference_image.py +72 -0
  71. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_losses.py +10 -7
  72. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_model.py +13 -4
  73. depth_estimation-0.1.3/tests/test_package.py +20 -0
  74. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_pipeline.py +6 -3
  75. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_processor.py +87 -1
  76. depth_estimation-0.1.3/tests/test_pruning.py +168 -0
  77. depth_estimation-0.1.3/tests/test_quantization.py +225 -0
  78. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_training.py +24 -11
  79. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_transforms.py +22 -4
  80. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_video.py +8 -2
  81. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/tests/test_viz.py +15 -3
  82. depth_estimation-0.1.1/tests/test_auto.py +0 -142
  83. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/LICENSE +0 -0
  84. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/setup.cfg +0 -0
  85. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/evaluation/__init__.py +0 -0
  86. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/__init__.py +0 -0
  87. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/auto/__init__.py +0 -0
  88. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/auto/modeling_auto.py +0 -0
  89. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/depth_pro/configuration_depth_pro.py +0 -0
  90. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/marigold_dc/configuration_marigold_dc.py +0 -0
  91. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/moge/configuration_moge.py +0 -0
  92. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/omnivggt/configuration_omnivggt.py +0 -0
  93. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/pixel_perfect_depth/configuration_ppd.py +0 -0
  94. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/vggt/configuration_vggt.py +0 -0
  95. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/models/zoedepth/configuration_zoedepth.py +0 -0
  96. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/output.py +0 -0
  97. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/pipelines/__init__.py +0 -0
  98. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/pipelines/depth_estimation.py +0 -0
  99. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation/viz/__init__.py +0 -0
  100. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation.egg-info/dependency_links.txt +0 -0
  101. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation.egg-info/entry_points.txt +0 -0
  102. {depth_estimation-0.1.1 → depth_estimation-0.1.3}/src/depth_estimation.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: depth_estimation
3
- Version: 0.1.1
3
+ Version: 0.1.3
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
@@ -9,7 +9,6 @@ Project-URL: Repository, https://github.com/shriarul5273/depth_estimation
9
9
  Project-URL: Issues, https://github.com/shriarul5273/depth_estimation/issues
10
10
  Keywords: depth-estimation,monocular-depth,computer-vision,deep-learning,pytorch,fine-tuning,training
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
@@ -18,10 +17,10 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
17
  Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
18
  Classifier: Intended Audience :: Developers
20
19
  Classifier: Intended Audience :: Science/Research
21
- Requires-Python: >=3.9
20
+ Requires-Python: >=3.10
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
- Requires-Dist: torch==2.9.0
23
+ Requires-Dist: torch>=2.0
25
24
  Requires-Dist: torchvision>=0.15
26
25
  Requires-Dist: Pillow>=9.0
27
26
  Requires-Dist: numpy>=1.24
@@ -39,34 +38,61 @@ Requires-Dist: tqdm
39
38
  Provides-Extra: dev
40
39
  Requires-Dist: pytest>=7.0; extra == "dev"
41
40
  Requires-Dist: pytest-cov; extra == "dev"
41
+ Requires-Dist: onnx>=1.14; extra == "dev"
42
+ Requires-Dist: onnxruntime; extra == "dev"
43
+ Requires-Dist: mypy>=1.10; extra == "dev"
44
+ Provides-Extra: export
45
+ Requires-Dist: onnx>=1.14; extra == "export"
42
46
  Dynamic: license-file
43
47
 
44
48
  # depth_estimation
45
49
 
46
50
  <p align="center">
51
+ <a href="https://github.com/shriarul5273/depth_estimation/actions/workflows/test.yml"><img alt="CI" src="https://github.com/shriarul5273/depth_estimation/actions/workflows/test.yml/badge.svg"></a>
47
52
  <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
53
  <a href="https://pypi.org/project/depth-estimation/"><img alt="PyPI" src="https://img.shields.io/pypi/v/depth-estimation"></a>
49
54
  <a href="https://pypi.org/project/depth-estimation/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/depth-estimation"></a>
55
+ <a href="https://pepy.tech/projects/depth-estimation"><img alt="PyPI Downloads" src="https://static.pepy.tech/personalized-badge/depth-estimation?period=total&units=INTERNATIONAL_SYSTEM&left_color=GREY&right_color=GREEN&left_text=downloads"></a>
50
56
  <a href="https://huggingface.co/spaces/shriarul5273/Depth-Estimation-Compare-demo"><img alt="Demo" src="https://img.shields.io/badge/🤗%20Hugging%20Face-Demo-blue"></a>
51
57
  </p>
52
58
 
53
59
  <h3 align="center">A unified Python library for monocular depth estimation</h3>
54
60
 
55
- <h3 align="center">Inference · Video & Streaming · Visualization · Fine-Tuning · Evaluation · Dataset Loading</h3>
61
+ <h3 align="center">Inference · Video · Training · Evaluation · ONNX Export · Pruning · Quantization</h3>
56
62
 
57
63
  ---
58
64
 
59
- `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.
65
+ `depth_estimation` is a unified model framework for monocular depth estimation. It provides one consistent API across **12 model families and 28 variants**, so you can swap models, compare them, fine-tune them, and prepare them for deployment without rewriting your pipeline.
60
66
 
61
- It covers the full workflow end-to-end: run inference with one line, stream depth from video, visualize results, evaluate on standard benchmarks, and fine-tune on custom depth data — all with the same library.
67
+ 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.
68
+
69
+ > **Latest release: v0.1.3 — Documentation Refresh.** It adds clearer installation paths, a documentation index, updated deployment guidance, and corrected ONNX verification dependencies. 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.1.3).
62
70
 
63
71
  ## Installation
64
72
 
65
73
  ```bash
66
- pip install depth-estimation
74
+ # Core library
75
+ pip install --upgrade depth-estimation
76
+
77
+ # ONNX export
78
+ pip install "depth-estimation[export]"
79
+
80
+ # Export verification and ONNX quantization
81
+ pip install "depth-estimation[export]" onnxruntime
67
82
  ```
68
83
 
69
- See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for optional extras (CUDA, MPS, etc.).
84
+ Python 3.10–3.12 is supported. 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.
85
+
86
+ ## Documentation
87
+
88
+ | Goal | Guide |
89
+ |---|---|
90
+ | Choose a model | [Models](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) |
91
+ | 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) |
92
+ | 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) |
93
+ | 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) |
94
+ | Use the command line | [CLI reference](https://github.com/shriarul5273/depth_estimation/blob/main/docs/cli.md) |
95
+ | Extend the library | [Adding a model](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) |
70
96
 
71
97
  ---
72
98
 
@@ -113,7 +139,7 @@ depth-estimate predict image.jpg --model depth-anything-v2-vitb
113
139
  Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
114
140
 
115
141
  **2. The full depth workflow in one place.**
116
- 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.
142
+ 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.
117
143
 
118
144
  **3. Modular, single-file model design.**
119
145
  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.
@@ -121,6 +147,9 @@ Each model lives in one self-contained file. No hidden abstractions. If you need
121
147
  **4. Designed for research.**
122
148
  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.
123
149
 
150
+ **5. Built for reliable deployment.**
151
+ Export verification checks ONNX output against PyTorch, quantization verifies accuracy by default, and unsupported model paths fail early with actionable errors.
152
+
124
153
  ---
125
154
 
126
155
  ## Supported Models
@@ -266,7 +295,8 @@ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/m
266
295
  <summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
267
296
 
268
297
  ```python
269
- from depth_estimation import DepthAnythingV2Model, DepthTrainer, DepthTrainingArguments, load_dataset
298
+ from depth_estimation import DepthTrainer, DepthTrainingArguments, load_dataset
299
+ from depth_estimation.models.depth_anything_v2 import DepthAnythingV2Model
270
300
  from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
271
301
 
272
302
  model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
@@ -298,6 +328,61 @@ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/do
298
328
 
299
329
  </details>
300
330
 
331
+ <details>
332
+ <summary><b>ONNX Export</b> — deploy outside PyTorch</summary>
333
+
334
+ ```python
335
+ from depth_estimation import AutoDepthModel, export_onnx
336
+
337
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
338
+ export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
339
+ ```
340
+
341
+ ```bash
342
+ # CLI
343
+ depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
344
+ ```
345
+
346
+ 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.
347
+
348
+ </details>
349
+
350
+ <details>
351
+ <summary><b>Pruning</b> — reduce effective parameter count</summary>
352
+
353
+ ```python
354
+ from depth_estimation import AutoDepthModel, prune_model, compute_sparsity
355
+
356
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
357
+ prune_model(model, amount=0.3) # zero out the smallest-magnitude 30% of weights
358
+ print(compute_sparsity(model)["overall"]) # ~0.3
359
+
360
+ model.export_onnx("pruned.onnx", verify=True) # pruned models export like any other
361
+ ```
362
+
363
+ 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).
364
+
365
+ For a complete prune → fine-tune → export → quantize workflow, see [`examples/optimize.py`](https://github.com/shriarul5273/depth_estimation/blob/main/examples/optimize.py).
366
+
367
+ </details>
368
+
369
+ <details>
370
+ <summary><b>Quantization</b> — float16/bfloat16/int8, plus ONNX int8/uint8</summary>
371
+
372
+ ```python
373
+ from depth_estimation import AutoDepthModel, quantize_onnx
374
+
375
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
376
+ model.quantize(dtype="float16") # in-place GPU precision cast
377
+
378
+ model.export_onnx("model.onnx")
379
+ quantize_onnx("model.onnx", "model_uint8.onnx") # default weight_type="uint8", verify=True
380
+ ```
381
+
382
+ `verify` defaults to `True` — quantization accuracy is **model-dependent, not reliably safe**: testing across the 28 registered variants found `uint8` produces badly wrong output for several real pretrained checkpoints, not just an edge case. See [docs/quantization.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/quantization.md) — including which formats are actually verified working (`int16`/`uint16` are **not**, despite being accepted by the underlying APIs, and `int8` needs `onnxruntime>=1.26.0` for models with `Conv2d` layers).
383
+
384
+ </details>
385
+
301
386
  ---
302
387
 
303
388
  ## Adding a New Model
@@ -1,29 +1,51 @@
1
1
  # depth_estimation
2
2
 
3
3
  <p align="center">
4
+ <a href="https://github.com/shriarul5273/depth_estimation/actions/workflows/test.yml"><img alt="CI" src="https://github.com/shriarul5273/depth_estimation/actions/workflows/test.yml/badge.svg"></a>
4
5
  <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
6
  <a href="https://pypi.org/project/depth-estimation/"><img alt="PyPI" src="https://img.shields.io/pypi/v/depth-estimation"></a>
6
7
  <a href="https://pypi.org/project/depth-estimation/"><img alt="Python" src="https://img.shields.io/pypi/pyversions/depth-estimation"></a>
8
+ <a href="https://pepy.tech/projects/depth-estimation"><img alt="PyPI Downloads" src="https://static.pepy.tech/personalized-badge/depth-estimation?period=total&units=INTERNATIONAL_SYSTEM&left_color=GREY&right_color=GREEN&left_text=downloads"></a>
7
9
  <a href="https://huggingface.co/spaces/shriarul5273/Depth-Estimation-Compare-demo"><img alt="Demo" src="https://img.shields.io/badge/🤗%20Hugging%20Face-Demo-blue"></a>
8
10
  </p>
9
11
 
10
12
  <h3 align="center">A unified Python library for monocular depth estimation</h3>
11
13
 
12
- <h3 align="center">Inference · Video & Streaming · Visualization · Fine-Tuning · Evaluation · Dataset Loading</h3>
14
+ <h3 align="center">Inference · Video · Training · Evaluation · ONNX Export · Pruning · Quantization</h3>
13
15
 
14
16
  ---
15
17
 
16
- `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.
18
+ `depth_estimation` is a unified model framework for monocular depth estimation. It provides one consistent API across **12 model families and 28 variants**, so you can swap models, compare them, fine-tune them, and prepare them for deployment without rewriting your pipeline.
17
19
 
18
- It covers the full workflow end-to-end: run inference with one line, stream depth from video, visualize results, evaluate on standard benchmarks, and fine-tune on custom depth data — all with the same library.
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.1.3 — Documentation Refresh.** It adds clearer installation paths, a documentation index, updated deployment guidance, and corrected ONNX verification dependencies. 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.1.3).
19
23
 
20
24
  ## Installation
21
25
 
22
26
  ```bash
23
- pip install depth-estimation
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
24
35
  ```
25
36
 
26
- See [docs/dependencies.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/dependencies.md) for optional extras (CUDA, MPS, etc.).
37
+ Python 3.10–3.12 is supported. 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.
38
+
39
+ ## Documentation
40
+
41
+ | Goal | Guide |
42
+ |---|---|
43
+ | Choose a model | [Models](https://github.com/shriarul5273/depth_estimation/blob/main/docs/models.md) |
44
+ | 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) |
45
+ | 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) |
46
+ | 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) |
47
+ | Use the command line | [CLI reference](https://github.com/shriarul5273/depth_estimation/blob/main/docs/cli.md) |
48
+ | Extend the library | [Adding a model](https://github.com/shriarul5273/depth_estimation/blob/main/docs/adding_a_model.md) |
27
49
 
28
50
  ---
29
51
 
@@ -70,7 +92,7 @@ depth-estimate predict image.jpg --model depth-anything-v2-vitb
70
92
  Switch from Depth Anything to DepthPro to MoGe by changing a single string. Preprocessing, postprocessing, and output format are identical across all models.
71
93
 
72
94
  **2. The full depth workflow in one place.**
73
- 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.
95
+ 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.
74
96
 
75
97
  **3. Modular, single-file model design.**
76
98
  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.
@@ -78,6 +100,9 @@ Each model lives in one self-contained file. No hidden abstractions. If you need
78
100
  **4. Designed for research.**
79
101
  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.
80
102
 
103
+ **5. Built for reliable deployment.**
104
+ Export verification checks ONNX output against PyTorch, quantization verifies accuracy by default, and unsupported model paths fail early with actionable errors.
105
+
81
106
  ---
82
107
 
83
108
  ## Supported Models
@@ -223,7 +248,8 @@ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/m
223
248
  <summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
224
249
 
225
250
  ```python
226
- from depth_estimation import DepthAnythingV2Model, DepthTrainer, DepthTrainingArguments, load_dataset
251
+ from depth_estimation import DepthTrainer, DepthTrainingArguments, load_dataset
252
+ from depth_estimation.models.depth_anything_v2 import DepthAnythingV2Model
227
253
  from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
228
254
 
229
255
  model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
@@ -255,6 +281,61 @@ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/do
255
281
 
256
282
  </details>
257
283
 
284
+ <details>
285
+ <summary><b>ONNX Export</b> — deploy outside PyTorch</summary>
286
+
287
+ ```python
288
+ from depth_estimation import AutoDepthModel, export_onnx
289
+
290
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
291
+ export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
292
+ ```
293
+
294
+ ```bash
295
+ # CLI
296
+ depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
297
+ ```
298
+
299
+ 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.
300
+
301
+ </details>
302
+
303
+ <details>
304
+ <summary><b>Pruning</b> — reduce effective parameter count</summary>
305
+
306
+ ```python
307
+ from depth_estimation import AutoDepthModel, prune_model, compute_sparsity
308
+
309
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
310
+ prune_model(model, amount=0.3) # zero out the smallest-magnitude 30% of weights
311
+ print(compute_sparsity(model)["overall"]) # ~0.3
312
+
313
+ model.export_onnx("pruned.onnx", verify=True) # pruned models export like any other
314
+ ```
315
+
316
+ 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).
317
+
318
+ For a complete prune → fine-tune → export → quantize workflow, see [`examples/optimize.py`](https://github.com/shriarul5273/depth_estimation/blob/main/examples/optimize.py).
319
+
320
+ </details>
321
+
322
+ <details>
323
+ <summary><b>Quantization</b> — float16/bfloat16/int8, plus ONNX int8/uint8</summary>
324
+
325
+ ```python
326
+ from depth_estimation import AutoDepthModel, quantize_onnx
327
+
328
+ model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
329
+ model.quantize(dtype="float16") # in-place GPU precision cast
330
+
331
+ model.export_onnx("model.onnx")
332
+ quantize_onnx("model.onnx", "model_uint8.onnx") # default weight_type="uint8", verify=True
333
+ ```
334
+
335
+ `verify` defaults to `True` — quantization accuracy is **model-dependent, not reliably safe**: testing across the 28 registered variants found `uint8` produces badly wrong output for several real pretrained checkpoints, not just an edge case. See [docs/quantization.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/quantization.md) — including which formats are actually verified working (`int16`/`uint16` are **not**, despite being accepted by the underlying APIs, and `int8` needs `onnxruntime>=1.26.0` for models with `Conv2d` layers).
336
+
337
+ </details>
338
+
258
339
  ---
259
340
 
260
341
  ## Adding a New Model
@@ -4,18 +4,17 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "depth_estimation"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  authors = [
9
9
  { name = "shriarul5273" },
10
10
  ]
11
11
  description = "A Transformers-style Python library for monocular depth estimation — inference, evaluation, and fine-tuning"
12
12
  readme = "README.md"
13
- requires-python = ">=3.9"
13
+ requires-python = ">=3.10"
14
14
  license = "MIT"
15
15
  license-files = ["LICENSE"]
16
16
  classifiers = [
17
17
  "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.9",
19
18
  "Programming Language :: Python :: 3.10",
20
19
  "Programming Language :: Python :: 3.11",
21
20
  "Programming Language :: Python :: 3.12",
@@ -27,7 +26,7 @@ classifiers = [
27
26
  ]
28
27
  keywords = ["depth-estimation", "monocular-depth", "computer-vision", "deep-learning", "pytorch", "fine-tuning", "training"]
29
28
  dependencies = [
30
- "torch==2.9.0",
29
+ "torch>=2.0",
31
30
  "torchvision>=0.15",
32
31
  "Pillow>=9.0",
33
32
  "numpy>=1.24",
@@ -53,6 +52,12 @@ Issues = "https://github.com/shriarul5273/depth_estimation/issues"
53
52
  dev = [
54
53
  "pytest>=7.0",
55
54
  "pytest-cov",
55
+ "onnx>=1.14",
56
+ "onnxruntime",
57
+ "mypy>=1.10",
58
+ ]
59
+ export = [
60
+ "onnx>=1.14",
56
61
  ]
57
62
 
58
63
  [project.scripts]
@@ -60,3 +65,29 @@ depth-estimate = "depth_estimation.cli:main"
60
65
 
61
66
  [tool.setuptools.packages.find]
62
67
  where = ["src"]
68
+
69
+ [tool.pytest.ini_options]
70
+ markers = [
71
+ "slow: heavy or network-dependent tests, excluded by default (run with -m slow)",
72
+ ]
73
+
74
+ [tool.ruff.lint]
75
+ # Keep Ruff's original default rule set explicit. Ruff 0.16 broadened its
76
+ # implicit defaults, which made unchanged code fail CI when the unpinned
77
+ # runner upgraded from 0.15.x.
78
+ select = ["E4", "E7", "E9", "F"]
79
+
80
+ [tool.ruff.lint.per-file-ignores]
81
+ # Model submodules are imported for their self-registration side effect
82
+ # (they call MODEL_REGISTRY.register(...) at import time) — not because
83
+ # their names are used directly here.
84
+ "src/depth_estimation/__init__.py" = ["F401"]
85
+
86
+ [tool.mypy]
87
+ python_version = "3.10"
88
+ ignore_missing_imports = true
89
+ # The codebase currently has ~290 pre-existing type errors (mostly missing
90
+ # annotations in older modules, not real bugs — verified by spot-checking
91
+ # several by hand). Fixing all of them is a separate, large effort; CI runs
92
+ # mypy in advisory (non-blocking) mode for now — see .github/workflows/test.yml.
93
+ # New code should still aim to be clean under this config.
@@ -27,77 +27,130 @@ from .models import omnivggt
27
27
  from .models import vggt
28
28
 
29
29
 
30
- def load_dataset(name, split="train", root=None, download=True, transform=None, **kwargs):
30
+ def load_dataset(
31
+ name, split="train", root=None, download=True, transform=None, **kwargs
32
+ ):
31
33
  """Load a depth dataset by name. See :mod:`depth_estimation.data` for details."""
32
34
  from .data import load_dataset as _load
33
- return _load(name, split=split, root=root, download=download, transform=transform, **kwargs)
35
+
36
+ return _load(
37
+ name, split=split, root=root, download=download, transform=transform, **kwargs
38
+ )
34
39
 
35
40
 
36
41
  def __getattr__(name):
37
42
  """Defer torch-heavy imports until first use."""
38
43
  if name == "BaseDepthModel":
39
44
  from .modeling_utils import BaseDepthModel
45
+
40
46
  globals()["BaseDepthModel"] = BaseDepthModel
41
47
  return BaseDepthModel
42
48
  if name == "DepthProcessor":
43
49
  from .processing_utils import DepthProcessor
50
+
44
51
  globals()["DepthProcessor"] = DepthProcessor
45
52
  return DepthProcessor
46
53
  if name == "DepthPipeline":
47
54
  from .pipeline_utils import DepthPipeline
55
+
48
56
  globals()["DepthPipeline"] = DepthPipeline
49
57
  return DepthPipeline
50
58
  if name == "pipeline":
51
59
  from .pipeline_utils import pipeline
60
+
52
61
  globals()["pipeline"] = pipeline
53
62
  return pipeline
54
63
  # Training symbols
55
64
  if name == "DepthTrainer":
56
65
  from .trainer import DepthTrainer
66
+
57
67
  globals()["DepthTrainer"] = DepthTrainer
58
68
  return DepthTrainer
59
69
  if name == "DepthTrainingArguments":
60
70
  from .training_args import DepthTrainingArguments
71
+
61
72
  globals()["DepthTrainingArguments"] = DepthTrainingArguments
62
73
  return DepthTrainingArguments
63
74
  if name == "CombinedDepthLoss":
64
75
  from .losses import CombinedDepthLoss
76
+
65
77
  globals()["CombinedDepthLoss"] = CombinedDepthLoss
66
78
  return CombinedDepthLoss
67
79
  if name == "ScaleInvariantLoss":
68
80
  from .losses import ScaleInvariantLoss
81
+
69
82
  globals()["ScaleInvariantLoss"] = ScaleInvariantLoss
70
83
  return ScaleInvariantLoss
71
84
  if name == "GradientLoss":
72
85
  from .losses import GradientLoss
86
+
73
87
  globals()["GradientLoss"] = GradientLoss
74
88
  return GradientLoss
75
89
  if name == "BerHuLoss":
76
90
  from .losses import BerHuLoss
91
+
77
92
  globals()["BerHuLoss"] = BerHuLoss
78
93
  return BerHuLoss
79
94
  if name == "get_train_transforms":
80
95
  from .data.transforms import get_train_transforms
96
+
81
97
  globals()["get_train_transforms"] = get_train_transforms
82
98
  return get_train_transforms
83
99
  if name == "get_val_transforms":
84
100
  from .data.transforms import get_val_transforms
101
+
85
102
  globals()["get_val_transforms"] = get_val_transforms
86
103
  return get_val_transforms
87
104
  # Video & streaming
88
105
  if name == "VideoStream":
89
106
  from .video import VideoStream
107
+
90
108
  globals()["VideoStream"] = VideoStream
91
109
  return VideoStream
92
110
  if name == "process_video":
93
111
  from .video import process_video
112
+
94
113
  globals()["process_video"] = process_video
95
114
  return process_video
96
115
  # Visualization toolkit
97
116
  if name == "viz":
98
117
  from . import viz
118
+
99
119
  globals()["viz"] = viz
100
120
  return viz
121
+ # ONNX export
122
+ if name == "export_onnx":
123
+ from .export import export_onnx
124
+
125
+ globals()["export_onnx"] = export_onnx
126
+ return export_onnx
127
+ # Pruning
128
+ if name == "prune_model":
129
+ from .pruning import prune_model
130
+
131
+ globals()["prune_model"] = prune_model
132
+ return prune_model
133
+ if name == "compute_sparsity":
134
+ from .pruning import compute_sparsity
135
+
136
+ globals()["compute_sparsity"] = compute_sparsity
137
+ return compute_sparsity
138
+ if name == "make_pruning_permanent":
139
+ from .pruning import make_pruning_permanent
140
+
141
+ globals()["make_pruning_permanent"] = make_pruning_permanent
142
+ return make_pruning_permanent
143
+ # Quantization
144
+ if name == "quantize_model":
145
+ from .quantization import quantize_model
146
+
147
+ globals()["quantize_model"] = quantize_model
148
+ return quantize_model
149
+ if name == "quantize_onnx":
150
+ from .quantization import quantize_onnx
151
+
152
+ globals()["quantize_onnx"] = quantize_onnx
153
+ return quantize_onnx
101
154
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
102
155
 
103
156
 
@@ -126,6 +179,22 @@ __all__ = [
126
179
  "process_video",
127
180
  # Visualization
128
181
  "viz",
182
+ # ONNX export
183
+ "export_onnx",
184
+ # Pruning
185
+ "prune_model",
186
+ "compute_sparsity",
187
+ "make_pruning_permanent",
188
+ # Quantization
189
+ "quantize_model",
190
+ "quantize_onnx",
129
191
  ]
130
192
 
131
- __version__ = "0.0.9"
193
+ try:
194
+ from importlib.metadata import PackageNotFoundError, version
195
+
196
+ __version__ = version("depth_estimation")
197
+ except PackageNotFoundError:
198
+ # Package not installed (e.g. running from a source checkout without
199
+ # `pip install -e .`) — no metadata to read the version from.
200
+ __version__ = "0.0.0+unknown"