Skip to main content

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 8 model families with 20 variants and designed to accommodate new models with minimal friction.

Installation

pip install depth-estimation

# With dev dependencies
pip install "depth-estimation[dev]"

# With all optional model dependencies
pip install "depth-estimation[all]"

For a full list of core and optional dependencies, see docs/dependencies.md.

Quick Start

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 20 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

8 model families · 20 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

  1. Create src/depth_estimation/models/your_model/
  2. Add configuration_your_model.py (inherit BaseDepthConfig)
  3. Add modeling_your_model.py (inherit BaseDepthModel, single file)
  4. Add __init__.py with MODEL_REGISTRY.register(...)

That's it — AutoDepthModel, AutoProcessor, and pipeline() will automatically resolve your model.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depth_estimation-0.0.5.tar.gz (68.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

depth_estimation-0.0.5-py3-none-any.whl (79.7 kB view details)

Uploaded Python 3

File details

Details for the file depth_estimation-0.0.5.tar.gz.

File metadata

  • Download URL: depth_estimation-0.0.5.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for depth_estimation-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a08e75b079f0e4e704797e4b2739fa30104be6430a02c8a76e0db14b9e40e0ad
MD5 3468c3a3072ff979761d06785719066d
BLAKE2b-256 2fd7e25bede659868aa3530f178368dd8d0442d20b61c1891c8c546339d203e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for depth_estimation-0.0.5.tar.gz:

Publisher: python-publish.yml on shriarul5273/depth_estimation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file depth_estimation-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for depth_estimation-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 604ed872ce7aedd9e35cb5f3e3e58fccaf5e62b604c7498d71704527329c49d6
MD5 9b0c28222f15dc9e9a71ebaefcb30b59
BLAKE2b-256 e6e292b5e4735896c35595d32305ccaa82abf938495c31c653a446f734ecbc24

See more details on using hashes here.

Provenance

The following attestation bundles were made for depth_estimation-0.0.5-py3-none-any.whl:

Publisher: python-publish.yml on shriarul5273/depth_estimation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page