🚀 Distill Any Depth Large - Transformers版本
Distill-Any-Depth是一個全新的單目深度估計模型,它採用了我們提出的知識蒸餾算法進行訓練,達到了當前最優水平。該模型在論文Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator中被首次提出。此模型的檢查點與transformers庫兼容,還提供了在線演示。
🚀 快速開始
本模型可用於零樣本深度估計,以下是使用方法。
💻 使用示例
基礎用法
使用pipeline
進行深度估計:
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="xingyang1/Distill-Any-Depth-Large-hf")
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
depth = pipe(image)["depth"]
高級用法
使用模型和處理器類進行深度估計:
from transformers import AutoImageProcessor, AutoModelForDepthEstimation
import torch
import numpy as np
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
image_processor = AutoImageProcessor.from_pretrained("xingyang1/Distill-Any-Depth-Large-hf")
model = AutoModelForDepthEstimation.from_pretrained("xingyang1/Distill-Any-Depth-Large-hf")
inputs = image_processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
post_processed_output = image_processor.post_process_depth_estimation(
outputs,
target_sizes=[(image.height, image.width)],
)
predicted_depth = post_processed_output[0]["predicted_depth"]
depth = (predicted_depth - predicted_depth.min()) / (predicted_depth.max() - predicted_depth.min())
depth = depth.detach().cpu().numpy() * 255
depth = Image.fromarray(depth.astype("uint8"))
📄 許可證
本項目採用MIT許可證。
📚 詳細文檔
如果您覺得本項目有用,請考慮引用以下文獻:
@article{he2025distill,
title = {Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator},
author = {Xiankang He and Dongyan Guo and Hongji Li and Ruibo Li and Ying Cui and Chi Zhang},
year = {2025},
journal = {arXiv preprint arXiv: 2502.19204}
}
👨💻 模型卡片作者
Parteek Kamboj
📋 模型信息