Depth Anything V2
Paper β’ 2406.09414 β’ Published β’ 105
ONNX export of depth-anything/Depth-Anything-V2-Small-hf, a monocular depth estimation model. Predicts relative inverse depth from a single RGB image β larger values are closer to the camera.
Mirrored for use with inference4j, an inference-only AI library for Java.
try (DepthAnythingEstimator estimator = DepthAnythingEstimator.builder()
.modelId("inference4j/depth-anything-v2-small")
.build()) {
DepthMap depth = estimator.estimate(Path.of("photo.jpg"));
System.out.println("Depth at centre: " + depth.at(depth.width() / 2, depth.height() / 2));
}
| Property | Value |
|---|---|
| Architecture | DINOv2 ViT-Small backbone + DPT decoder |
| Task | Monocular depth estimation |
| Parameters | ~25M |
| Input | [1, 3, height, width] β NCHW float32, RGB |
| Normalization | ImageNet mean [0.485, 0.456, 0.406], std [0.229, 0.224, 0.225] |
| Input sizing | 518 on the longer edge, aspect preserved, both dimensions rounded up to a multiple of 14 (ViT patch size), bicubic resampling |
| Output name | predicted_depth |
| Output | [1, height, width] β rank 3, no channel dimension |
| Output semantics | Relative inverse depth; larger is closer. Scale is per-image, not metric. |
| Original framework | PyTorch (HuggingFace Transformers) |
This model is licensed under the Apache 2.0 License. Original model by Depth Anything, ONNX export by onnx-community.
(pixel / 255 - mean) / std[0.485, 0.456, 0.406][0.229, 0.224, 0.225][1, 3, H, W]The output is relative inverse depth, so values are only comparable within a single image.
To render a depth map, normalize to [0, 1] against the per-image min and max, then resize
back to the original image dimensions.
Yang, L., Kang, B., Huang, Z., Zhao, Z., Xu, X., Feng, J., & Zhao, H. (2024). Depth Anything V2. NeurIPS 2024. arXiv:2406.09414