开源项目最佳实践:Prior-Depth-Anything
2025-05-19 16:25:48作者:江焘钦
1. 项目介绍
Prior-Depth-Anything 是一个开源项目,旨在结合不完整但精确的深度测量度量和相对但完整的几何结构深度预测,为任何场景生成准确、密集和详细的度量化深度图。该框架通过整合先验深度信息与图像内容,提高了深度估计的精度和鲁棒性。
2. 项目快速启动
环境准备
首先,确保您的系统中安装了 Python 3.9,然后克隆仓库并创建一个新的虚拟环境:
git clone https://github.com/SpatialVision/Prior-Depth-Anything.git
conda create -n priorda python=3.9
conda activate priorda
cd Prior-Depth-Anything
安装依赖
接下来,安装项目所需的依赖:
pip install -r requirements.txt
或者,您可以选择将 Prior-Depth-Anything 安装为包:
pip install -e .
运行示例
运行以下命令来执行 CLI 演示。首次执行时,模型权重将自动从 Hugging Face Model Hub 下载:
priorda test --image_path assets/sample-1/rgb.jpg --prior_path assets/sample-1/gt_depth.png --pattern downscale_32 --visualize 1
或者,您可以使用 Python 代码来运行演示:
import torch
from prior_depth_anything import PriorDepthAnything
device = "cuda:0" if torch.cuda.is_available() else "cpu"
priorda = PriorDepthAnything(device=device)
image_path = 'assets/sample-2/rgb.jpg'
prior_path = 'assets/sample-2/prior_depth.png'
output = priorda.infer_one_sample(image=image_path, prior=prior_path, visualize=True)
运行完成后,结果将保存到 ./output 目录中。
3. 应用案例和最佳实践
使用 Prior-Depth-Anything 作为插件
Prior-Depth-Anything 展示了出色的零样本鲁棒性,即使在多变且可能嘈杂的先验输入存在下也能工作。它可以作为一个即插即用的模块,集成到其他深度估计框架中,提高其性能。
以下是一个使用 VGGT 模型的示例:
- 使用 VGGT 模型预测深度图。
- 使用 Prior-Depth-Anything 来细化深度图。
import torch
from vggt.models.vggt import VGGT
from vggt.utils.load_fn import load_and_preprocess_images
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] >= 8 else torch.float16
model = VGGT.from_pretrained("facebook/VGGT-1B").to(device)
image_names = ['assets/sample-2/rgb.jpg']
images = load_and_preprocess_images(image_names).to(device)
with torch.no_grad():
with torch.cuda.amp.autocast(dtype=dtype):
predictions = model(images)
然后,使用 Prior-Depth-Anything 细化深度图。
from PIL import Image
import numpy as np
import torch.nn.functional as F
from prior_depth_anything.plugin import PriorDARefiner, PriorDARefinerMetrics
Refiner = PriorDARefiner(device=device)
priorda_image = torch.from_numpy(np.asarray(Image.open(image_names[0])).astype(np.uint8))
depth_map, depth_conf = predictions['depth'], predictions['depth_conf']
refined_depth, meview_depth_map = Refiner.predict(image=priorda_image, depth_map=depth_map.squeeze(), confidence=depth_conf.squeeze())
4. 典型生态项目
目前,Prior-Depth-Anything 主要与 VGGT 等深度估计框架集成。未来,开发者可以将其集成到更多的深度估计项目中,形成一个更加丰富和多样化的技术生态。
登录后查看全文
热门项目推荐
kernelopenEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。C0113
let_datasetLET数据集 基于全尺寸人形机器人 Kuavo 4 Pro 采集,涵盖多场景、多类型操作的真实世界多任务数据。面向机器人操作、移动与交互任务,支持真实环境下的可扩展机器人学习00
mindquantumMindQuantum is a general software library supporting the development of applications for quantum computation.Python059
PaddleOCR-VLPaddleOCR-VL 是一款顶尖且资源高效的文档解析专用模型。其核心组件为 PaddleOCR-VL-0.9B,这是一款精简却功能强大的视觉语言模型(VLM)。该模型融合了 NaViT 风格的动态分辨率视觉编码器与 ERNIE-4.5-0.3B 语言模型,可实现精准的元素识别。Python00
GLM-4.7-FlashGLM-4.7-Flash 是一款 30B-A3B MoE 模型。作为 30B 级别中的佼佼者,GLM-4.7-Flash 为追求性能与效率平衡的轻量化部署提供了全新选择。Jinja00
最新内容推荐
项目优选
收起
deepin linux kernel
C
27
11
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
487
3.61 K
Ascend Extension for PyTorch
Python
298
332
暂无简介
Dart
738
177
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
270
113
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
865
467
仓颉编译器源码及 cjdb 调试工具。
C++
149
880
React Native鸿蒙化仓库
JavaScript
296
343
Dora SSR 是一款跨平台的游戏引擎,提供前沿或是具有探索性的游戏开发功能。它内置了Web IDE,提供了可以轻轻松松通过浏览器访问的快捷游戏开发环境,特别适合于在新兴市场如国产游戏掌机和其它移动电子设备上直接进行游戏开发和编程学习。
C++
52
7
🔥LeetCode solutions in any programming language | 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
Java
65
20