Depth Anything V2
Use Depth Anything V2 for monocular depth estimation on a Dedicated Deployment or self-hosted Inference
Code sample
3
Run the model
import os
import cv2
import numpy as np
import supervision as sv
from inference_sdk import InferenceHTTPClient
image = sv.load_image_from_url("https://media.roboflow.com/notebooks/examples/bicycle.png")
client = InferenceHTTPClient(
api_url="https://your-deployment.roboflow.cloud",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.depth_estimation(image)
depth = np.array(result["normalized_depth"], dtype=np.float32)
depth = cv2.resize(depth, (image.shape[1], image.shape[0]))
depth_vis = (depth * 255).astype(np.uint8)
depth_color = cv2.applyColorMap(depth_vis, cv2.COLORMAP_INFERNO)
cv2.imwrite("depth_annotated.png", np.hstack([image, depth_color]))
Inference speed
Model
Latency (ms)
Available models
Response formats
Use with Inference (self-hosted)
Execution modes in Workflows
Last updated
Was this helpful?