Views
No views yet

We present a foundation model for zero-shot metric monocular depth estimation. Our model, Depth Pro, synthesizes high-resolution depth maps with unparalleled sharpness and high-frequency details. The predictions are metric, with absolute scale, without relying on the availability of metadata such as camera intrinsics. And the model is fast, producing a 2.25-megapixel depth map in 0.3 seconds on a standard GPU. These characteristics are enabled by a number of technical contributions, including an efficient multi-scale vision transformer for dense prediction, a training protocol that combines real and synthetic datasets to achieve high metric accuracy alongside fine boundary tracing, dedicated evaluation metrics for boundary accuracy in estimated depth maps, and state-of-the-art focal length estimation from a single image. Extensive experiments analyze specific design choices and demonstrate that Depth Pro outperforms prior work along multiple dimensions.
1import requests
2from PIL import Image
3import torch
4from transformers import DepthProImageProcessorFast, DepthProForDepthEstimation
5
6device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
8url = 'https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg'
9image = Image.open(requests.get(url, stream=True).raw)
10
11image_processor = DepthProImageProcessorFast.from_pretrained("apple/DepthPro-hf")
12model = DepthProForDepthEstimation.from_pretrained("apple/DepthPro-hf").to(device)
13
14inputs = image_processor(images=image, return_tensors="pt").to(device)
15
16with torch.no_grad():
17 outputs = model(**inputs)
18
19post_processed_output = image_processor.post_process_depth_estimation(
20 outputs, target_sizes=[(image.height, image.width)],
21)
22
23field_of_view = post_processed_output[0]["field_of_view"]
24focal_length = post_processed_output[0]["focal_length"]
25depth = post_processed_output[0]["predicted_depth"]
26depth = (depth - depth.min()) / (depth.max() - depth.min())
27depth = depth * 255.
28depth = depth.detach().cpu().numpy()
29depth = Image.fromarray(depth.astype("uint8"))
1/225.mean=[0.5, 0.5, 0.5] and std=[0.5, 0.5, 0.5]1536x1536 pixels


DepthProForDepthEstimation model uses a DepthProEncoder, for encoding the input image and a FeatureFusionStage for fusing the output features from encoder.DepthProEncoder further uses two encoders:patch_encoder
scaled_images_ratios configuration.patch_size with overlapping areas determined by scaled_images_overlap_ratios.patch_encoderimage_encoder
patch_size and processed by the image_encoderpatch_model_config and image_model_config respectively, both of which are separate Dinov2Model by default.last_hidden_state) and selected intermediate states (hidden_states) from patch_encoder are fused by a DPT-based FeatureFusionStage for depth estimation.1@misc{bochkovskii2024depthprosharpmonocular,
2 title={Depth Pro: Sharp Monocular Metric Depth in Less Than a Second},
3 author={Aleksei Bochkovskii and Amaël Delaunoy and Hugo Germain and Marcel Santos and Yichao Zhou and Stephan R. Richter and Vladlen Koltun},
4 year={2024},
5 eprint={2410.02073},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2410.02073},
9}