🚀 轻量级深度蒸馏模型 - Transformers版本
Distill-Any-Depth是一种全新的单目深度估计模型,它采用了我们提出的知识蒸馏算法进行训练,达到了当前最优水平(SOTA)。该模型在论文 Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator 中被首次提出。此模型的检查点与transformers库兼容,你可以通过 在线演示 体验其效果。
🚀 快速开始
以下是使用该模型进行零样本深度估计的方法:
基础用法
from transformers import pipeline
from PIL import Image
import requests
pipe = pipeline(task="depth-estimation", model="xingyang1/Distill-Any-Depth-Small-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-Small-hf")
model = AutoModelForDepthEstimation.from_pretrained("xingyang1/Distill-Any-Depth-Small-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
📋 模型信息