A Transformers-style Python library for monocular depth estimation
Project description
depth_estimation
A Python library for monocular depth estimation.
Provides a unified, modular API for running inference, comparing, and integrating depth estimation models — supporting 12 model families with 28 variants and designed to accommodate new models with minimal friction.
Installation
pip install depth-estimation
For a full list of core and optional dependencies, see docs/dependencies.md.
Quick Start
| Pipeline API | Auto Classes | |
|---|---|---|
| Setup | One call, model + processor bundled | Load model and processor separately |
| Inference | Pass image path directly | Call processor(), model(), postprocess() manually |
| Control | Low — handles everything for you | High — you control each step |
| Output | DepthOutput with .depth, .colored_depth, .metadata |
Raw depth tensor |
| Best for | Quick inference, scripts, demos | Custom pipelines, research, fine-grained control |
Pipeline API (Recommended)
from depth_estimation import pipeline
pipe = pipeline("depth-estimation", model="depth-anything-v2-vitb")
result = pipe("image.jpg")
depth_map = result.depth # np.ndarray, float32, (H, W)
colored = result.colored_depth # np.ndarray, uint8, (H, W, 3)
meta = result.metadata # dict with model info
Auto Classes
from depth_estimation import AutoDepthModel, AutoProcessor
# Works with any of the 25 supported variants
model = AutoDepthModel.from_pretrained("zoedepth")
processor = AutoProcessor.from_pretrained("zoedepth")
inputs = processor("image.jpg")
with torch.no_grad():
depth = model(inputs["pixel_values"])
result = processor.postprocess(depth, inputs["original_sizes"])
Batch Inference
results = pipe(["img1.jpg", "img2.jpg", "img3.jpg"])
for r in results:
print(r.depth.shape)
Supported Models
12 model families · 28 variants — see docs/models.md for the full list.
Architecture
The library follows the HuggingFace Transformers modular design philosophy:
- Single model, single file — each model's architecture is self-contained
- Shared processor — preprocessing/postprocessing is not duplicated
- Registry-based auto-loading — new models self-register, no core changes needed
- Config inheritance — configs override only what differs from the base
Input → Processor.preprocess() → Model.forward() → Processor.postprocess() → DepthOutput
Adding a New Model
- Create
src/depth_estimation/models/your_model/ - Add
configuration_your_model.py(inheritBaseDepthConfig) - Add
modeling_your_model.py(inheritBaseDepthModel, single file) - Add
__init__.pywithMODEL_REGISTRY.register(...)
That's it — AutoDepthModel, AutoProcessor, and pipeline() will automatically resolve your model.
CLI
After installing the package, a depth-estimate command is available.
# Single image → saves demo10_depth.png
depth-estimate predict demo10.png --model depth-anything-v2-vitb
# Batch (directory or glob) → saves to results/
depth-estimate predict "images/*.jpg" --model depth-anything-v2-vitb --output-dir results/
# Video → saves side-by-side RGB | depth as MP4
depth-estimate predict video.mp4 --model depth-anything-v2-vitb --output depth_video.mp4
# Save raw float32 array (.npy) alongside the PNG
depth-estimate predict demo10.png --model depth-anything-v2-vitb --format both
# Change colormap
depth-estimate predict demo10.png --model depth-anything-v2-vitb --colormap inferno
# List all available models
depth-estimate list-models
# Show config details for a model
depth-estimate info depth-anything-v2-vitb
Global flags (--device, --quiet, --verbose) go before the subcommand:
depth-estimate --device cpu --quiet predict demo10.png --model depth-anything-v2-vitb
All subcommands support --json for machine-readable output.
For full documentation see docs/cli.md.
Running Tests
pip install -e ".[dev]"
pytest tests/ -v
Acknowledgments
This library builds upon the incredible work of the following research teams:
| Model | Repository |
|---|---|
| Depth Anything v1 | github.com/LiheYoung/Depth-Anything |
| Depth Anything v2 | github.com/DepthAnything/Depth-Anything-V2 |
| Depth Anything v3 | github.com/DepthAnything/Depth-Anything-V3 |
| DINOv2 | github.com/facebookresearch/dinov2 |
| DepthPro | github.com/apple/ml-depth-pro |
| ZoeDepth | github.com/isl-org/ZoeDepth |
| MiDaS | github.com/isl-org/MiDaS |
| Pixel-Perfect Depth | github.com/gangweix/Pixel-Perfect-Depth |
| Marigold-DC | github.com/prs-eth/Marigold-DC |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file depth_estimation-0.0.7.tar.gz.
File metadata
- Download URL: depth_estimation-0.0.7.tar.gz
- Upload date:
- Size: 114.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6d63ba7b9bb3364e71cff32849946c879c73f641cb112bfebd47a570cd7c426
|
|
| MD5 |
be2a2f3bf85b7e05ff00463137d7f7fc
|
|
| BLAKE2b-256 |
6afbbb88931028cd929e0389ba2d750ce93d1c9e4658ae4751eec6b815e8d1f5
|
Provenance
The following attestation bundles were made for depth_estimation-0.0.7.tar.gz:
Publisher:
python-publish.yml on shriarul5273/depth_estimation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
depth_estimation-0.0.7.tar.gz -
Subject digest:
e6d63ba7b9bb3364e71cff32849946c879c73f641cb112bfebd47a570cd7c426 - Sigstore transparency entry: 1091408277
- Sigstore integration time:
-
Permalink:
shriarul5273/depth_estimation@c6d03528623f616c50ade8d4b2f8f09abb210acf -
Branch / Tag:
refs/tags/v0.0.7 - Owner: https://github.com/shriarul5273
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c6d03528623f616c50ade8d4b2f8f09abb210acf -
Trigger Event:
release
-
Statement type:
File details
Details for the file depth_estimation-0.0.7-py3-none-any.whl.
File metadata
- Download URL: depth_estimation-0.0.7-py3-none-any.whl
- Upload date:
- Size: 130.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5db19ceec8e8bd1e85ca4ea82961411ffeefd057a9abb3defe5c3d32223e1f87
|
|
| MD5 |
799d03b84bf3c52a881e6c4037f7d768
|
|
| BLAKE2b-256 |
2ff5559e586862799703c034ed45dec07c66e5ad3760f41138329a01515d02b7
|
Provenance
The following attestation bundles were made for depth_estimation-0.0.7-py3-none-any.whl:
Publisher:
python-publish.yml on shriarul5273/depth_estimation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
depth_estimation-0.0.7-py3-none-any.whl -
Subject digest:
5db19ceec8e8bd1e85ca4ea82961411ffeefd057a9abb3defe5c3d32223e1f87 - Sigstore transparency entry: 1091408281
- Sigstore integration time:
-
Permalink:
shriarul5273/depth_estimation@c6d03528623f616c50ade8d4b2f8f09abb210acf -
Branch / Tag:
refs/tags/v0.0.7 - Owner: https://github.com/shriarul5273
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c6d03528623f616c50ade8d4b2f8f09abb210acf -
Trigger Event:
release
-
Statement type: