Distill Any Depth Large hf

提供商xingyang1
分类depth-estimation
许可证mit
下载量201.6K
星标0

简介

Distill Any Depth Large 是一款高效的单目深度估计模型,旨在将复杂的深度感知能力通过知识蒸馏简化,从而在保证精度的前提下提升推理速度。对于开发者而言,它解决了传统深度模型计算量大、部署难的痛点,能够将 2D 图像快速转化为高质量的深度图。该模型非常适合集成到 AR 增强现实、机器人视觉避障以及 3D 场景重建等实际项目中。上手门槛较低,支持 Hugging Face 生态,可轻松替代部分重量级视觉模型,在端侧设备上实现更流畅的实时深度感知。

核心亮点

  • 通过知识蒸馏实现高性能与低延迟的平衡
  • 精准的单目深度估计,支持 2D 转 3D 视觉分析
  • 适配 MIT 协议,方便开发者快速集成至商业项目
  • 兼容 Hugging Face 生态,部署与调用流程简单

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("xingyang1/Distill-Any-Depth-Large-hf")
tokenizer = AutoTokenizer.from_pretrained("xingyang1/Distill-Any-Depth-Large-hf")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download xingyang1/Distill-Any-Depth-Large-hf

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download xingyang1/Distill-Any-Depth-Large-hf config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('xingyang1/Distill-Any-Depth-Large-hf')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/xingyang1/Distill-Any-Depth-Large-hf

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/xingyang1/Distill-Any-Depth-Large-hf

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('xingyang1/Distill-Any-Depth-Large-hf')
tokenizer = AutoTokenizer.from_pretrained('xingyang1/Distill-Any-Depth-Large-hf')

完整文档

来源: HuggingFace

---
library_name: transformers
license: mit
pipeline_tag: depth-estimation
arxiv: <2502.19204>
tags:

  • distill-any-depth

  • vision

---

Distill Any Depth Large - Transformers Version

Introduction

We present Distill-Any-Depth, a new SOTA monocular depth estimation model trained with our proposed knowledge distillation algorithms. It was introduced in the paper Distill Any Depth: Distillation Creates a Stronger Monocular Depth Estimator.

This model checkpoint is compatible with the transformers library.

Online demo.

How to use

Here is how to use this model to perform zero-shot depth estimation:

python
from transformers import pipeline
from PIL import Image
import requests

load pipe

pipe = pipeline(task="depth-estimation", model="xingyang1/Distill-Any-Depth-Large-hf")

load image

url = 'http://images.cocodataset.org/val2017/000000039769.jpg' image = Image.open(requests.get(url, stream=True).raw)

inference

depth = pipe(image)["depth"]

Alternatively, you can use the model and processor classes:

python
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")

prepare image for the model

inputs = image_processor(images=image, return_tensors="pt")

with torch.no_grad():
outputs = model(**inputs)

interpolate to original size and visualize the prediction

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"))
)

If you find this project useful, please consider citing:

bibtex
@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}
}

Model Card Author

Parteek Kamboj