Views
No views yet
1import requests
2from PIL import Image
3from transformers import PromptDepthAnythingForDepthEstimation, PromptDepthAnythingImageProcessor
4
5url = "https://github.com/DepthAnything/PromptDA/blob/main/assets/example_images/image.jpg?raw=true"
6image = Image.open(requests.get(url, stream=True).raw)
7
8
9image_processor = PromptDepthAnythingImageProcessor.from_pretrained("depth-anything/prompt-depth-anything-vitl-hf")
10model = PromptDepthAnythingForDepthEstimation.from_pretrained("depth-anything/prompt-depth-anything-vitl-hf")
11
12prompt_depth_url = "https://github.com/DepthAnything/PromptDA/blob/main/assets/example_images/arkit_depth.png?raw=true"
13prompt_depth = Image.open(requests.get(prompt_depth_url, stream=True).raw)
14
15inputs = image_processor(images=image, return_tensors="pt", prompt_depth=prompt_depth)
16with torch.no_grad():
17 outputs = model(**inputs)
18post_processed_output = image_processor.post_process_depth_estimation(
19 outputs,
20 target_sizes=[(image.height, image.width)],
21)
22
23predicted_depth = post_processed_output[0]["predicted_depth"]
241@inproceedings{lin2024promptda,
2 title={Prompting Depth Anything for 4K Resolution Accurate Metric Depth Estimation},
3 author={Lin, Haotong and Peng, Sida and Chen, Jingxiao and Peng, Songyou and Sun, Jiaming and Liu, Minghuan and Bao, Hujun and Feng, Jiashi and Zhou, Xiaowei and Kang, Bingyi},
4 journal={arXiv},
5 year={2024}
6}