$ show DepthAnything/Depth-Anything-V2
Depth Anything V2 is a research codebase for monocular depth estimation, providing both relative and metric depth models. It builds on a DINOv2 encoder with a DPT decoder, offering four model scales (Small, Base, Large, Giant). The repository includes inference scripts for images and videos, a Gradio demo, and a subdirectory for fine-tuning on metric depth estimation using Hypersim (indoor) and Virtual KITTI 2 (outdoor) datasets. It also defines the DA-2K evaluation benchmark for relative depth. The code is well-structured with reusable transform utilities and evaluation metrics, but reproducibility is limited due to hardcoded dataset paths and unpinned dependencies. This is primarily a research project with a hybrid nature due to the included demo application.
The LLM identified 3 files worth highlighting for reuse:
A parameterized Resize class that supports multiple resize strategies (lower_bound, upper_bound, minimal), aspect ratio preservation, and constraining output dimensions to a multiple of a given value. It is self-contained, well-documented, and can be reused in any computer vision pipeline requiring flexible image resizing.
Implements SiLogLoss, a scale-invariant logarithmic loss for depth estimation. It computes the mean squared error of log differences with a lambda term to reduce scale dependence. The implementation is clean and reusable for other depth regression tasks.
Provides a function eval_depth that computes standard depth estimation metrics (d1, d2, d3, abs_rel, sq_rel, rmse, rmse_log, log10, silog) from predicted and target depth maps. The function is self-contained and can be reused to evaluate any depth model.