A PyTorch-free depth estimator that beats PyTorch on CPU
It exists to turn a single photo into metric depth, camera pose, and a 3D point cloud using nothing but a native binary—no Python stack required.

What it does
depth-anything.cpp is a from-scratch C++17 rewrite of ByteDance’s Depth Anything 3 built on ggml. Feed it an image and it spits out a dense metric depth map, per-pixel confidence, the camera’s intrinsic and extrinsic matrices, an optional sky mask, and a back-projected 3D point cloud. Everything ships as one self-contained GGUF file and a small native library, with no Python runtime or PyTorch installation required at inference time. It also ingests the older Depth Anything V2 checkpoints if you only need single-image depth.
The interesting bit
The project is obsessed with numerical parity: every tensor is checked against PyTorch reference dumps, and the final depth correlates at 1.0 with the original. The CPU speedup over PyTorch came from an almost absurd bottleneck—cached positional embeddings that the original recomputed every forward pass with single-threaded scalar math. On GPU it ties PyTorch’s tuned cuDNN path while loading nearly twice as fast, and the whole thing can squeeze down to a 99 MB q4_k quant.
Key highlights
- Bit-exact output against the official PyTorch model (correlation 1.0), verified component by component.
- Self-contained GGUF format bakes every hyperparameter and preprocessing constant into the model file; no external config or vocabulary needed.
- CPU inference is faster than PyTorch (1.31× at
q8_0) while using roughly half the RAM; GPU performance matchescuDNNwith a quicker cold start. - Exports to
glb,COLMAP, andPLYusing dependency-free writers that are parity-checked against the reference exporters. - Flat C API and LocalAI backend integration mean you can embed it or hit a REST endpoint without touching the CLI.
Verdict
Worth a look if you need monocular depth or camera pose inside a C++ application, an edge device, or a LocalAI pipeline without dragging in a Python environment. Skip it if you are already comfortable inside PyTorch and don’t care about binary size or cold-start latency.
Frequently asked
- What is localai-org/depth-anything.cpp?
- It exists to turn a single photo into metric depth, camera pose, and a 3D point cloud using nothing but a native binary—no Python stack required.
- Is depth-anything.cpp open source?
- Yes — localai-org/depth-anything.cpp is open source, released under the MIT license.
- What language is depth-anything.cpp written in?
- localai-org/depth-anything.cpp is primarily written in C++.
- How popular is depth-anything.cpp?
- localai-org/depth-anything.cpp has 1.1k stars on GitHub.
- Where can I find depth-anything.cpp?
- localai-org/depth-anything.cpp is on GitHub at https://github.com/localai-org/depth-anything.cpp.