Depth Anything V2 Small β€” ONNX

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.

Original Source

Usage with inference4j

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));
}

Model Details

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)

License

This model is licensed under the Apache 2.0 License. Original model by Depth Anything, ONNX export by onnx-community.

Preprocessing

  1. Resize so the longer edge is 518, preserving aspect ratio (bicubic)
  2. Round both dimensions up to a multiple of 14 (the ViT patch size)
  3. ImageNet normalization: (pixel / 255 - mean) / std
    • mean = [0.485, 0.456, 0.406]
    • std = [0.229, 0.224, 0.225]
  4. NCHW layout: [1, 3, H, W]

Postprocessing

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.

Original Paper

Yang, L., Kang, B., Huang, Z., Zhao, Z., Xu, X., Feng, J., & Zhao, H. (2024). Depth Anything V2. NeurIPS 2024. arXiv:2406.09414

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Paper for inference4j/depth-anything-v2-small