Views
No views yet
1from transformers import AutoModelForDepthEstimation, AutoImageProcessor
2import torch
3from PIL import Image
4
5# Load model and processor
6model = AutoModelForDepthEstimation.from_pretrained("takara-ai/DepthPro-Safetensors")
7processor = AutoImageProcessor.from_pretrained("takara-ai/DepthPro-Safetensors")
8
9# Prepare image
10image = Image.open("your_image.jpg")
11inputs = processor(images=image, return_tensors="pt")
12
13# Inference
14with torch.no_grad():
15 outputs = model(**inputs)
16 predicted_depth = outputs.predicted_depth
17
18# Post-process for visualization
19depth_map = processor.post_process_depth_estimation(outputs, target_size=image.size[::-1])1@article{Bochkovskii2024:arxiv,
2 author = {Aleksei Bochkovskii and Ama\"{e}l Delaunoy and Hugo Germain and Marcel Santos and
3 Yichao Zhou and Stephan R. Richter and Vladlen Koltun},
4 title = {Depth Pro: Sharp Monocular Metric Depth in Less Than a Second},
5 journal = {arXiv},
6 year = {2024},
7}人類を変革する