Depth Anything V2

Depth Anything V2 is a DINOv2 encoder paired with a DPT decoder that predicts a dense relative inverse-depth map from a single image. LibreYOLO supports it for the depth task: predict and zero-shot validation, with no training path.

Tasks
depth
Sizes
s, b, l, g at 518 px
Install
pip install libreyolo
Support tier
Inference only, since v. Predict, validate and export only. Training features do not apply.
Upstream
Depth Anything V2 by The University of Hong Kong and TikTok, Apache-2.0 (Small checkpoint); CC-BY-NC-4.0 (Base and Large checkpoints). Paper, source
Licenses
Code Apache-2.0, weights Apache-2.0 (Small checkpoint); CC-BY-NC-4.0 (Base and Large checkpoints). Commercial use

Install

Depth Anything V2 needs no optional extra. Everything it imports is in the base install.

bash
pip install libreyolo

Predict

Weights download from Hugging Face on first use and are cached locally.

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreDepthAnythingV2s-depth.pt")result = model(SAMPLE_IMAGE, save=True) depth = result.depth_mapprint(depth.min, depth.max, depth.mean)
CLI
libreyolo predict model=LibreDepthAnythingV2s-depth.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True
Read the depth map
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreDepthAnythingV2s-depth.pt")result = model(SAMPLE_IMAGE) depth = result.depth_map    # DepthMap: dense (H, W), higher = closerraw = depth.data                # tensor, no metric unit or cross-image scalenormalized = depth.normalized() # rescaled to [0, 1] for visualization

result.depth_map carries a dense relative inverse-depth map: higher values mean closer to the camera, and the values have no metric unit or cross-image scale. save=True writes a colormapped visualization of that map to disk; Results.plot() does not cover this family, since it is defined for surface normals and edges only. Input resolution must divide evenly by 14, the DINOv2 patch grid the DPT head builds on; LibreYOLO checks this before running and raises if it does not. See prediction for sources, streaming and result handling.

Variants

Four encoder sizes, s/b/l/g, corresponding to ViT-S/B/L/G. The checkpoint table below lists only s, b and l; no Giant checkpoint is published. All four share the same input resolution, so choosing a size trades encoder capacity, not image size. Licensing is also a factor: the Small checkpoint is Apache-2.0, while Base and Large are CC-BY-NC-4.0, see Licensing below.

Training and fine-tuning are not offered for this family. LibreDepthAnythingV2.train() raises NotImplementedError unconditionally; convert a compatible upstream checkpoint instead, with weights/convert_depth_anything_v2_weights.py.

Validate

val() runs the shared depth validator: it aligns each prediction to its ground truth with a per-image least-squares scale and shift, then reports the standard zero-shot relative-depth metrics, AbsRel, RMSE and the three delta thresholds.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreDepthAnythingV2s-depth.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/abs_rel"])print(metrics["metrics/rmse"])print(metrics["metrics/delta1"])
CLI
libreyolo val model=LibreDepthAnythingV2s-depth.pt data=my-dataset.yaml

Export

TaskONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
depthdepth to ONNX: supported. depth to TorchScript: supported. depth to ExecuTorch: supported. depth to TensorRT: supported. depth to OpenVINO: supported. depth to Paddle: not supporteddepth to MNN: not supporteddepth to RKNN: not supporteddepth to ncnn: not supporteddepth to TFLite: not supporteddepth to CoreML: not supporteddepth to Core AI: supported.

An exported artifact loads back through LibreYOLO() on its file suffix, so a .onnx or .engine file behaves like a checkpoint and returns the same Results, with depth_map in place of boxes. Export lists the arguments every format accepts.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreDepthAnythingV2s-depth.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibreDepthAnythingV2s-depth.pt format=onnxlibreyolo export model=LibreDepthAnythingV2s-depth.pt format=tensorrt half=True
Use the exported file
from libreyolo import LibreYOLO, SAMPLE_IMAGE # The factory routes on the file suffix, so an exported artifact loads# like any checkpoint and returns the same Results object.model = LibreYOLO("LibreDepthAnythingV2s-depth.onnx")result = model(SAMPLE_IMAGE) print(result.depth_map.data.shape)

Checkpoints

Every published weight file for this family.

FileInput (px)Weights license
depth
LibreDepthAnythingV2s-depth.ptapache-2.0
LibreDepthAnythingV2l-depth.ptcc-by-nc-4.0
LibreDepthAnythingV2b-depth.ptcc-by-nc-4.0

Every file above exists in the LibreYOLO org today and downloads on first use.

Licensing

Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.

This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.

Original work
Depth Anything V2, The University of Hong Kong and TikTok
Upstream license
Apache-2.0 (Small checkpoint); CC-BY-NC-4.0 (Base and Large checkpoints)
LibreYOLO code
MIT
Weights
Apache-2.0 (Small checkpoint); CC-BY-NC-4.0 (Base and Large checkpoints), republished at huggingface.co/LibreYOLO
Interpretation
The two licenses are not interchangeable. The Small checkpoint is Apache-2.0, a permissive license: it can be used in commercial and closed-source products, it asks you to keep its license text and attribution notices with any redistributed copy, and it grants a patent license. The Base and Large checkpoints are CC-BY-NC-4.0, which forbids commercial use outright and requires attribution on any redistribution, so treat them as research and evaluation weights unless you obtain separate terms from the authors. LibreYOLO's own code for this family is MIT throughout, and training is not offered for this family so there is no self-trained-weights exception to reach for.

Citation

@article{depth_anything_v2,
  title={Depth Anything V2},
  author={Yang, Lihe and Kang, Bingyi and Huang, Zilong and Zhao, Zhen and Xu, Xiaogang and Feng, Jiashi and Zhao, Hengshuang},
  journal={arXiv:2406.09414},
  year={2024}
}

Copied from the authors' citation block at github.com/DepthAnything/Depth-Anything-V2#citation.

Verified against LibreYOLO v1.5.0. Support tables, checkpoints and benchmark numbers on this page are generated from the released library and the published weights, not written by hand.