开源项目最佳实践: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 StartedRust0187
cann-learning-hubCANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。Jupyter Notebook0112
Step-3.7-FlashStep-3.7-Flash是一个拥有 1980 亿参数的稀疏混合专家(MoE)视觉语言模型,由 1960 亿参数的语言主干网络和 18 亿参数的视觉编码器组合而成,具备原生图像理解能力。Python00
JoyAI-EchoJoyAI-Echo,这是一个独立的、仅用于推理的版本,旨在实现分钟级多镜头音视频生成。它采用了经过蒸馏的DMD生成器、配对的跨模态记忆以及故事级别的一致性。其性能的核心在于,一个跨模态视听记忆库能够在长达五分钟的视频中保持角色外观和语音音色的一致性。同时,一个训练后处理流程将基于记忆的强化学习与分布匹配蒸馏相结合,实现了7.5倍的速度提升,显著增强了视觉质量和对齐效果。00
omega-aiOmega-AI:基于java打造的深度学习框架,帮助你快速搭建神经网络,实现模型推理与训练,引擎支持自动求导,多线程与GPU运算,GPU支持CUDA,CUDNN。Java03
llm-universe本项目是一个面向小白开发者的大模型应用开发教程,在线阅读地址:https://datawhalechina.github.io/llm-universe/Jupyter Notebook08
热门内容推荐
最新内容推荐
项目优选
收起
deepin linux kernel
C
32
16
暂无描述
Dockerfile
759
4.94 K
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
1.78 K
187
暂无简介
Dart
1 K
259
Ascend Extension for PyTorch
Python
716
866
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
854
1.91 K
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
1.07 K
1.09 K
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.72 K
1.02 K
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
674
1.32 K
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
454
436