开源项目最佳实践: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 等深度估计框架集成。未来,开发者可以将其集成到更多的深度估计项目中,形成一个更加丰富和多样化的技术生态。
登录后查看全文
热门项目推荐
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust069- DDeepSeek-V4-ProDeepSeek-V4-Pro(总参数 1.6 万亿,激活 49B)面向复杂推理和高级编程任务,在代码竞赛、数学推理、Agent 工作流等场景表现优异,性能接近国际前沿闭源模型。Python00
MiniMax-M2.7MiniMax-M2.7 是我们首个深度参与自身进化过程的模型。M2.7 具备构建复杂智能体应用框架的能力,能够借助智能体团队、复杂技能以及动态工具搜索,完成高度精细的生产力任务。Python00
GLM-5.1GLM-5.1是智谱迄今最智能的旗舰模型,也是目前全球最强的开源模型。GLM-5.1大大提高了代码能力,在完成长程任务方面提升尤为显著。和此前分钟级交互的模型不同,它能够在一次任务中独立、持续工作超过8小时,期间自主规划、执行、自我进化,最终交付完整的工程级成果。Jinja00
Kimi-K2.6Kimi K2.6 是一款开源的原生多模态智能体模型,在长程编码、编码驱动设计、主动自主执行以及群体任务编排等实用能力方面实现了显著提升。Python00
Hy3-previewHy3 preview 是由腾讯混元团队研发的2950亿参数混合专家(Mixture-of-Experts, MoE)模型,包含210亿激活参数和38亿MTP层参数。Hy3 preview是在我们重构的基础设施上训练的首款模型,也是目前发布的性能最强的模型。该模型在复杂推理、指令遵循、上下文学习、代码生成及智能体任务等方面均实现了显著提升。Python00
项目优选
收起
暂无描述
Dockerfile
687
4.45 K
Ascend Extension for PyTorch
Python
540
664
Claude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed.
Get Started
Rust
388
69
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
953
919
本项目是CANN开源社区的核心管理仓库,包含社区的治理章程、治理组织、通用操作指引及流程规范等基础信息
646
230
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
407
322
Oohos_react_native
React Native鸿蒙化仓库
C++
336
385
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.59 K
923
昇腾LLM分布式训练框架
Python
145
172
暂无简介
Dart
935
234