depth-estimation 0.1.0__tar.gz → 0.1.2__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.0 → depth_estimation-0.1.2}/LICENSE +0 -0
- {depth_estimation-0.1.0/src/depth_estimation.egg-info → depth_estimation-0.1.2}/PKG-INFO +141 -7
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/README.md +133 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/pyproject.toml +35 -4
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/__init__.py +91 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/cli.py +197 -42
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/configuration_utils.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/__init__.py +4 -7
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/base_dataset.py +1 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/diode.py +2 -4
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/folder.py +5 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/hub.py +37 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/kitti.py +5 -8
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/nyu_depth_v2.py +10 -14
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/data/transforms.py +47 -30
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/evaluation/__init__.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/evaluation/evaluate.py +48 -33
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/evaluation/metrics.py +71 -46
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/evaluation/profiling.py +15 -13
- depth_estimation-0.1.2/src/depth_estimation/export.py +301 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/losses.py +6 -2
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/modeling_utils.py +114 -4
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/__init__.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/auto/__init__.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/auto/modeling_auto.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/auto/processing_auto.py +2 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v1/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v1/configuration_depth_anything_v1.py +1 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v1/modeling_depth_anything_v1.py +173 -43
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v2/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v2/configuration_depth_anything_v2.py +4 -2
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v2/modeling_depth_anything_v2.py +397 -126
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v3/__init__.py +4 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v3/configuration_depth_anything_v3.py +6 -6
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_anything_v3/modeling_depth_anything_v3.py +257 -77
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_pro/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_pro/configuration_depth_pro.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/depth_pro/modeling_depth_pro.py +79 -27
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/marigold_dc/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/marigold_dc/configuration_marigold_dc.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/marigold_dc/modeling_marigold_dc.py +68 -30
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/midas/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/midas/configuration_midas.py +14 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/midas/modeling_midas.py +3 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/moge/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/moge/configuration_moge.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/moge/modeling_moge.py +1136 -421
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/omnivggt/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/omnivggt/configuration_omnivggt.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/omnivggt/modeling_omnivggt.py +861 -283
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/pixel_perfect_depth/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/pixel_perfect_depth/configuration_ppd.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/pixel_perfect_depth/modeling_ppd.py +76 -34
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/vggt/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/vggt/configuration_vggt.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/vggt/modeling_vggt.py +663 -223
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/zoedepth/__init__.py +2 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/zoedepth/configuration_zoedepth.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/models/zoedepth/modeling_zoedepth.py +20 -6
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/output.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/pipeline_utils.py +94 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/pipelines/__init__.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/pipelines/depth_estimation.py +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/processing_utils.py +24 -15
- depth_estimation-0.1.2/src/depth_estimation/pruning.py +216 -0
- depth_estimation-0.1.2/src/depth_estimation/quantization.py +284 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/registry.py +1 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/trainer.py +19 -11
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation/training_args.py +13 -6
- depth_estimation-0.1.2/src/depth_estimation/video.py +263 -0
- depth_estimation-0.1.2/src/depth_estimation/viz/__init__.py +45 -0
- depth_estimation-0.1.2/src/depth_estimation/viz/animate.py +89 -0
- depth_estimation-0.1.2/src/depth_estimation/viz/composite.py +85 -0
- depth_estimation-0.1.2/src/depth_estimation/viz/display.py +108 -0
- depth_estimation-0.1.2/src/depth_estimation/viz/error.py +72 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2/src/depth_estimation.egg-info}/PKG-INFO +141 -7
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation.egg-info/SOURCES.txt +19 -1
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation.egg-info/requires.txt +7 -1
- depth_estimation-0.1.2/tests/test_auto.py +174 -0
- depth_estimation-0.1.2/tests/test_cli.py +279 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_config.py +48 -26
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_data.py +85 -4
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_evaluation.py +15 -3
- depth_estimation-0.1.2/tests/test_export_onnx.py +402 -0
- depth_estimation-0.1.2/tests/test_inference_all_models.py +161 -0
- depth_estimation-0.1.2/tests/test_inference_image.py +72 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_losses.py +10 -7
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_model.py +13 -4
- depth_estimation-0.1.2/tests/test_package.py +20 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_pipeline.py +6 -3
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_processor.py +87 -1
- depth_estimation-0.1.2/tests/test_pruning.py +168 -0
- depth_estimation-0.1.2/tests/test_quantization.py +225 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_training.py +24 -11
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/tests/test_transforms.py +22 -4
- depth_estimation-0.1.2/tests/test_video.py +249 -0
- depth_estimation-0.1.2/tests/test_viz.py +191 -0
- depth_estimation-0.1.0/tests/test_auto.py +0 -142
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/setup.cfg +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation.egg-info/dependency_links.txt +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation.egg-info/entry_points.txt +0 -0
- {depth_estimation-0.1.0 → depth_estimation-0.1.2}/src/depth_estimation.egg-info/top_level.txt +0 -0
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: depth_estimation
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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.
|
|
20
|
+
Requires-Python: >=3.10
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: torch
|
|
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,25 +38,33 @@ 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>
|
|
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>
|
|
50
57
|
</p>
|
|
51
58
|
|
|
52
59
|
<h3 align="center">A unified Python library for monocular depth estimation</h3>
|
|
53
60
|
|
|
54
|
-
<h3 align="center">Inference · Fine-Tuning · Evaluation · Dataset Loading</h3>
|
|
61
|
+
<h3 align="center">Inference · Video & Streaming · Visualization · Fine-Tuning · Evaluation · Dataset Loading</h3>
|
|
55
62
|
|
|
56
63
|
---
|
|
57
64
|
|
|
58
65
|
`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
66
|
|
|
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.
|
|
67
|
+
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.
|
|
61
68
|
|
|
62
69
|
## Installation
|
|
63
70
|
|
|
@@ -165,6 +172,79 @@ depth-estimate predict "images/*.jpg" --model depth-anything-v2-vitb --output-di
|
|
|
165
172
|
|
|
166
173
|
</details>
|
|
167
174
|
|
|
175
|
+
<details>
|
|
176
|
+
<summary><b>Video & Streaming</b> — frame-by-frame depth from video, webcam, or image sequences</summary>
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from depth_estimation import pipeline
|
|
180
|
+
|
|
181
|
+
pipe = pipeline("depth-estimation", model="depth-anything-v2-vitb")
|
|
182
|
+
|
|
183
|
+
# Stream a video file — yields DepthOutput per frame
|
|
184
|
+
for result in pipe.stream("video.mp4", temporal_smoothing=0.5):
|
|
185
|
+
depth = result.depth # (H, W) float32
|
|
186
|
+
colored = result.colored_depth # (H, W, 3) uint8
|
|
187
|
+
print(result.metadata["frame_index"])
|
|
188
|
+
|
|
189
|
+
# Webcam stream
|
|
190
|
+
for result in pipe.stream(0): # device index
|
|
191
|
+
...
|
|
192
|
+
|
|
193
|
+
# Frame glob (sorted alphabetically)
|
|
194
|
+
for result in pipe.stream("frames/*.png"):
|
|
195
|
+
...
|
|
196
|
+
|
|
197
|
+
# Write output video to disk
|
|
198
|
+
pipe.process_video(
|
|
199
|
+
"input.mp4",
|
|
200
|
+
"output_depth.mp4",
|
|
201
|
+
colormap="inferno",
|
|
202
|
+
side_by_side=True, # RGB | depth composite
|
|
203
|
+
temporal_smoothing=0.5,
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# CLI — video prediction
|
|
209
|
+
depth-estimate predict video.mp4 --model depth-anything-v2-vitb --output depth_video.mp4
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
See [docs/video.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/video.md).
|
|
213
|
+
|
|
214
|
+
</details>
|
|
215
|
+
|
|
216
|
+
<details>
|
|
217
|
+
<summary><b>Visualization</b> — depth maps, comparisons, overlays, 3D animations, error maps</summary>
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from depth_estimation.viz import (
|
|
221
|
+
show_depth, compare_depths, overlay_depth,
|
|
222
|
+
create_anaglyph, animate_3d, plot_error_map,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# Display a depth result
|
|
226
|
+
show_depth(result, colormap="Spectral_r", title="Depth Anything V2")
|
|
227
|
+
|
|
228
|
+
# Side-by-side comparison of multiple models
|
|
229
|
+
compare_depths([result_v2, result_pro], labels=["DA V2", "DepthPro"], save="compare.png")
|
|
230
|
+
|
|
231
|
+
# Blend depth over RGB image
|
|
232
|
+
overlay = overlay_depth(image, result.depth, alpha=0.5, colormap="inferno")
|
|
233
|
+
|
|
234
|
+
# Red-cyan anaglyph stereo image
|
|
235
|
+
anaglyph = create_anaglyph(image, result.depth, baseline=0.065)
|
|
236
|
+
|
|
237
|
+
# Rotating 3D surface animation
|
|
238
|
+
animate_3d(image, result.depth, "rotation.gif", frames=60)
|
|
239
|
+
|
|
240
|
+
# Per-pixel error heatmap (requires ground truth)
|
|
241
|
+
plot_error_map(pred_depth, gt_depth, metric="abs_rel", save="errors.png")
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
See [docs/viz.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/viz.md).
|
|
245
|
+
|
|
246
|
+
</details>
|
|
247
|
+
|
|
168
248
|
<details>
|
|
169
249
|
<summary><b>Evaluation</b> — standard benchmarks, custom predictions</summary>
|
|
170
250
|
|
|
@@ -192,7 +272,8 @@ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/m
|
|
|
192
272
|
<summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
|
|
193
273
|
|
|
194
274
|
```python
|
|
195
|
-
from depth_estimation import
|
|
275
|
+
from depth_estimation import DepthTrainer, DepthTrainingArguments, load_dataset
|
|
276
|
+
from depth_estimation.models.depth_anything_v2 import DepthAnythingV2Model
|
|
196
277
|
from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
|
|
197
278
|
|
|
198
279
|
model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
|
|
@@ -224,6 +305,59 @@ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/do
|
|
|
224
305
|
|
|
225
306
|
</details>
|
|
226
307
|
|
|
308
|
+
<details>
|
|
309
|
+
<summary><b>ONNX Export</b> — deploy outside PyTorch</summary>
|
|
310
|
+
|
|
311
|
+
```python
|
|
312
|
+
from depth_estimation import AutoDepthModel, export_onnx
|
|
313
|
+
|
|
314
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
315
|
+
export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
# CLI
|
|
320
|
+
depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge`. `zoedepth` and `marigold-dc` are **not exportable** (both wrap an opaque external pipeline) — `export_onnx()` raises a clear error immediately rather than a doomed attempt. Requires the optional `onnx` package: `pip install "depth-estimation[export]"`. GPU inference on the exported file works too via `onnxruntime-gpu`. See [docs/export.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) for the full supported-models table, known limitations, and GPU setup.
|
|
324
|
+
|
|
325
|
+
</details>
|
|
326
|
+
|
|
327
|
+
<details>
|
|
328
|
+
<summary><b>Pruning</b> — reduce effective parameter count</summary>
|
|
329
|
+
|
|
330
|
+
```python
|
|
331
|
+
from depth_estimation import AutoDepthModel, prune_model, compute_sparsity
|
|
332
|
+
|
|
333
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
334
|
+
prune_model(model, amount=0.3) # zero out the smallest-magnitude 30% of weights
|
|
335
|
+
print(compute_sparsity(model)["overall"]) # ~0.3
|
|
336
|
+
|
|
337
|
+
model.export_onnx("pruned.onnx", verify=True) # pruned models export like any other
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
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
|
+
|
|
342
|
+
</details>
|
|
343
|
+
|
|
344
|
+
<details>
|
|
345
|
+
<summary><b>Quantization</b> — float16/bfloat16/int8, plus ONNX int8/uint8</summary>
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
from depth_estimation import AutoDepthModel, quantize_onnx
|
|
349
|
+
|
|
350
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
351
|
+
model.quantize(dtype="float16") # in-place GPU precision cast
|
|
352
|
+
|
|
353
|
+
model.export_onnx("model.onnx")
|
|
354
|
+
quantize_onnx("model.onnx", "model_uint8.onnx") # default weight_type="uint8", verify=True
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
`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).
|
|
358
|
+
|
|
359
|
+
</details>
|
|
360
|
+
|
|
227
361
|
---
|
|
228
362
|
|
|
229
363
|
## Adding a New Model
|
|
@@ -1,20 +1,23 @@
|
|
|
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>
|
|
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>
|
|
7
10
|
</p>
|
|
8
11
|
|
|
9
12
|
<h3 align="center">A unified Python library for monocular depth estimation</h3>
|
|
10
13
|
|
|
11
|
-
<h3 align="center">Inference · Fine-Tuning · Evaluation · Dataset Loading</h3>
|
|
14
|
+
<h3 align="center">Inference · Video & Streaming · Visualization · Fine-Tuning · Evaluation · Dataset Loading</h3>
|
|
12
15
|
|
|
13
16
|
---
|
|
14
17
|
|
|
15
18
|
`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
19
|
|
|
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.
|
|
20
|
+
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.
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
20
23
|
|
|
@@ -122,6 +125,79 @@ depth-estimate predict "images/*.jpg" --model depth-anything-v2-vitb --output-di
|
|
|
122
125
|
|
|
123
126
|
</details>
|
|
124
127
|
|
|
128
|
+
<details>
|
|
129
|
+
<summary><b>Video & Streaming</b> — frame-by-frame depth from video, webcam, or image sequences</summary>
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from depth_estimation import pipeline
|
|
133
|
+
|
|
134
|
+
pipe = pipeline("depth-estimation", model="depth-anything-v2-vitb")
|
|
135
|
+
|
|
136
|
+
# Stream a video file — yields DepthOutput per frame
|
|
137
|
+
for result in pipe.stream("video.mp4", temporal_smoothing=0.5):
|
|
138
|
+
depth = result.depth # (H, W) float32
|
|
139
|
+
colored = result.colored_depth # (H, W, 3) uint8
|
|
140
|
+
print(result.metadata["frame_index"])
|
|
141
|
+
|
|
142
|
+
# Webcam stream
|
|
143
|
+
for result in pipe.stream(0): # device index
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
# Frame glob (sorted alphabetically)
|
|
147
|
+
for result in pipe.stream("frames/*.png"):
|
|
148
|
+
...
|
|
149
|
+
|
|
150
|
+
# Write output video to disk
|
|
151
|
+
pipe.process_video(
|
|
152
|
+
"input.mp4",
|
|
153
|
+
"output_depth.mp4",
|
|
154
|
+
colormap="inferno",
|
|
155
|
+
side_by_side=True, # RGB | depth composite
|
|
156
|
+
temporal_smoothing=0.5,
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# CLI — video prediction
|
|
162
|
+
depth-estimate predict video.mp4 --model depth-anything-v2-vitb --output depth_video.mp4
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
See [docs/video.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/video.md).
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
<details>
|
|
170
|
+
<summary><b>Visualization</b> — depth maps, comparisons, overlays, 3D animations, error maps</summary>
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from depth_estimation.viz import (
|
|
174
|
+
show_depth, compare_depths, overlay_depth,
|
|
175
|
+
create_anaglyph, animate_3d, plot_error_map,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Display a depth result
|
|
179
|
+
show_depth(result, colormap="Spectral_r", title="Depth Anything V2")
|
|
180
|
+
|
|
181
|
+
# Side-by-side comparison of multiple models
|
|
182
|
+
compare_depths([result_v2, result_pro], labels=["DA V2", "DepthPro"], save="compare.png")
|
|
183
|
+
|
|
184
|
+
# Blend depth over RGB image
|
|
185
|
+
overlay = overlay_depth(image, result.depth, alpha=0.5, colormap="inferno")
|
|
186
|
+
|
|
187
|
+
# Red-cyan anaglyph stereo image
|
|
188
|
+
anaglyph = create_anaglyph(image, result.depth, baseline=0.065)
|
|
189
|
+
|
|
190
|
+
# Rotating 3D surface animation
|
|
191
|
+
animate_3d(image, result.depth, "rotation.gif", frames=60)
|
|
192
|
+
|
|
193
|
+
# Per-pixel error heatmap (requires ground truth)
|
|
194
|
+
plot_error_map(pred_depth, gt_depth, metric="abs_rel", save="errors.png")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
See [docs/viz.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/viz.md).
|
|
198
|
+
|
|
199
|
+
</details>
|
|
200
|
+
|
|
125
201
|
<details>
|
|
126
202
|
<summary><b>Evaluation</b> — standard benchmarks, custom predictions</summary>
|
|
127
203
|
|
|
@@ -149,7 +225,8 @@ See [docs/evaluation.md](https://github.com/shriarul5273/depth_estimation/blob/m
|
|
|
149
225
|
<summary><b>Fine-Tuning</b> — any trainable model, any depth dataset</summary>
|
|
150
226
|
|
|
151
227
|
```python
|
|
152
|
-
from depth_estimation import
|
|
228
|
+
from depth_estimation import DepthTrainer, DepthTrainingArguments, load_dataset
|
|
229
|
+
from depth_estimation.models.depth_anything_v2 import DepthAnythingV2Model
|
|
153
230
|
from depth_estimation.data.transforms import get_train_transforms, get_val_transforms
|
|
154
231
|
|
|
155
232
|
model = DepthAnythingV2Model.from_pretrained("depth-anything-v2-vits", for_training=True)
|
|
@@ -181,6 +258,59 @@ See [docs/data.md](https://github.com/shriarul5273/depth_estimation/blob/main/do
|
|
|
181
258
|
|
|
182
259
|
</details>
|
|
183
260
|
|
|
261
|
+
<details>
|
|
262
|
+
<summary><b>ONNX Export</b> — deploy outside PyTorch</summary>
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from depth_estimation import AutoDepthModel, export_onnx
|
|
266
|
+
|
|
267
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
268
|
+
export_onnx(model, "depth_anything_v2_vitb.onnx", input_size=518, verify=True)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# CLI
|
|
273
|
+
depth-estimate export --model depth-anything-v2-vitb --output model.onnx --verify
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Verified working for `depth-anything-v1/v2/v3`, `depth-pro`, and `moge`. `zoedepth` and `marigold-dc` are **not exportable** (both wrap an opaque external pipeline) — `export_onnx()` raises a clear error immediately rather than a doomed attempt. Requires the optional `onnx` package: `pip install "depth-estimation[export]"`. GPU inference on the exported file works too via `onnxruntime-gpu`. See [docs/export.md](https://github.com/shriarul5273/depth_estimation/blob/main/docs/export.md) for the full supported-models table, known limitations, and GPU setup.
|
|
277
|
+
|
|
278
|
+
</details>
|
|
279
|
+
|
|
280
|
+
<details>
|
|
281
|
+
<summary><b>Pruning</b> — reduce effective parameter count</summary>
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
from depth_estimation import AutoDepthModel, prune_model, compute_sparsity
|
|
285
|
+
|
|
286
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
287
|
+
prune_model(model, amount=0.3) # zero out the smallest-magnitude 30% of weights
|
|
288
|
+
print(compute_sparsity(model)["overall"]) # ~0.3
|
|
289
|
+
|
|
290
|
+
model.export_onnx("pruned.onnx", verify=True) # pruned models export like any other
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
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
|
+
|
|
295
|
+
</details>
|
|
296
|
+
|
|
297
|
+
<details>
|
|
298
|
+
<summary><b>Quantization</b> — float16/bfloat16/int8, plus ONNX int8/uint8</summary>
|
|
299
|
+
|
|
300
|
+
```python
|
|
301
|
+
from depth_estimation import AutoDepthModel, quantize_onnx
|
|
302
|
+
|
|
303
|
+
model = AutoDepthModel.from_pretrained("depth-anything-v2-vitb")
|
|
304
|
+
model.quantize(dtype="float16") # in-place GPU precision cast
|
|
305
|
+
|
|
306
|
+
model.export_onnx("model.onnx")
|
|
307
|
+
quantize_onnx("model.onnx", "model_uint8.onnx") # default weight_type="uint8", verify=True
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`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).
|
|
311
|
+
|
|
312
|
+
</details>
|
|
313
|
+
|
|
184
314
|
---
|
|
185
315
|
|
|
186
316
|
## 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.
|
|
7
|
+
version = "0.1.2"
|
|
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.
|
|
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
|
|
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,63 +27,130 @@ from .models import omnivggt
|
|
|
27
27
|
from .models import vggt
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
def load_dataset(
|
|
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
|
-
|
|
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
|
|
104
|
+
# Video & streaming
|
|
105
|
+
if name == "VideoStream":
|
|
106
|
+
from .video import VideoStream
|
|
107
|
+
|
|
108
|
+
globals()["VideoStream"] = VideoStream
|
|
109
|
+
return VideoStream
|
|
110
|
+
if name == "process_video":
|
|
111
|
+
from .video import process_video
|
|
112
|
+
|
|
113
|
+
globals()["process_video"] = process_video
|
|
114
|
+
return process_video
|
|
115
|
+
# Visualization toolkit
|
|
116
|
+
if name == "viz":
|
|
117
|
+
from . import viz
|
|
118
|
+
|
|
119
|
+
globals()["viz"] = viz
|
|
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
|
|
87
154
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
88
155
|
|
|
89
156
|
|
|
@@ -107,6 +174,27 @@ __all__ = [
|
|
|
107
174
|
"BerHuLoss",
|
|
108
175
|
"get_train_transforms",
|
|
109
176
|
"get_val_transforms",
|
|
177
|
+
# Video & streaming
|
|
178
|
+
"VideoStream",
|
|
179
|
+
"process_video",
|
|
180
|
+
# Visualization
|
|
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",
|
|
110
191
|
]
|
|
111
192
|
|
|
112
|
-
|
|
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"
|