fabiotosi92/ZipDepth
[ECCV 2026] Official implementation of "ZipDepth: Bringing Lightweight Zero-Shot Monocular Depth Anywhere, on Any Device". A compact 6.1M-parameter network for zero-shot monocular depth estimation, running in real time from server GPUs to mobile phones via knowledge distillation from foundation models.
📦 什么是 ZipDepth?
ZipDepth 是在 ECCV 2026 上提出的一种轻量级、零样本单目深度估计模型。它无需任何任务特定的微调,即可从单张 RGB 图像预测密集深度图。其核心优势在于 精度-效率权衡:在保持模型大小仅为约 6 M 参数的同时,达到与大型 Transformer 基础模型相当的性能,并在现代 GPU 上实现 >1 k FPS 的运行速度(在移动/边缘硬件上也表现良好)。
🔑 核心思想
| 组件 | 功能 |
|---|---|
| 编码器 | 由 RepVGG 可重参数化卷积构建的四阶段层次结构。早期阶段使用 条带池化注意力 获取水平/垂直上下文;后期阶段增加 挤压-激励 和 全局上下文块。 |
| 颈部 | 多尺度池化(SPPF)与 跨尺度融合 模块,用于在解码前融合特征。 |
| 解码器 | 紧凑的特征金字塔网络(FPN),搭配 凸上采样 头部,生成亚像素级精度的深度图。 |
| 两个检查点 | zipdepth_base.pth(GPU 友好,使用 torch.nn.Unfold)和 zipdepth_base_npu.pth(无 Unfold,更易转换为 ONNX/CoreML/TFLite 用于移动/NPU)。 |
🚀 快速上手
# 克隆并安装
git clone https://github.com/fabiotosi92/ZipDepth
cd ZipDepth
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt # 需要 PyTorch ≥2.4
pip install -e .
推理(单张图像、文件夹或视频)
python scripts/infer.py \
--checkpoint checkpoints/zipdepth_base.pth \
--input assets/examples/im0.jpg \
--input-size 384 # 短边,四舍五入为 32 的倍数
可选参数:--fp16(半精度)、--compile(torch.compile)、--npu(使用 NPU 兼容检查点)、--no-colormap / --save-raw 用于输出原始 .npy 深度数据。
导出模型
- ONNX(推荐用于移动/边缘设备):
python scripts/export.py \ --ckpt checkpoints/zipdepth_base_npu.pth \ --format onnx --height 384 --width 384 --npu - TorchScript(追踪或冻结)用于纯 PyTorch 部署。
📊 性能概览
| 数据集 | 参数量 | GFLOPs(384×384) | 典型延迟(RTX 3090) |
|---|---|---|---|
| NYUv2, KITTI, ETH3D, ScanNet, DIODE | ~6.1 M | ~0.9 G | 0.8 ms(TensorRT FP16)→ ≈1300 FPS |
论文中的帕累托图显示,ZipDepth 在轻量级模型区域占据主导地位,同时与最佳大型模型性能相差仅几个百分点。
🛠️ 训练(研究导向)
- 数据:通过从 Depth Anything V2 Large 知识蒸馏,在 17 个公开图像领域(如 COCO、Cityscapes、MegaDepth 等)生成的 1400 万对 RGB-深度图像。文件路径列表以
training_files.txt.gz提供;实际图像需从原始数据集获取。 - 流程:
scripts/prepare_index.py构建 JSON 索引 → 可选转换为 NumPy 内存映射以实现快速 I/O。 - 启动(单 GPU 示例):
多 GPU 通过python scripts/train.py --config configs/default.jsontorchrun和标准 DDP 实现。 - 损失函数:尺度与平移不变深度损失 + 梯度正则化,使用 AdamW 和 One-Cycle 学习率调度进行优化。
📱 在设备上部署
- 选择 NPU 友好检查点(
zipdepth_base_npu.pth)。 - 导出为 ONNX(
scripts/export.py --format onnx --npu)。 - 将 ONNX 模型转换为目标运行时(ONNX Runtime Mobile、CoreML、TFLite、NCNN 等)。
- 上采样头部仅使用移动 NPU 广泛支持的操作,确保转换过程干净无误。
🙏 致谢与引用
作者感谢 Marigold(提供评估协议)和 Depth Anything V2(提供伪标签)的创建者。若在研究中使用 ZipDepth,请引用:
@inproceedings{tosi2026zipdepth,
title = {ZipDepth: Bringing Lightweight Zero-Shot Monocular Depth Anywhere, on Any Device},
author = {Tosi, Fabio and Bartolomei, Luca and Poggi, Matteo and Mattoccia, Stefano},
booktitle = {European Conference on Computer Vision (ECCV)},
year = {2026}
}
📧 联系方式
如有疑问,请通过 README 中列出的邮箱联系作者。
相关
- 项目
- 项目
- 项目
- 项目