Depth Anything 3 度量深度估计模型适配昇腾NPU版本。
| 参数 | 值 |
|---|---|
| Model Name | da3metric-large |
| Task | 单目度量深度估计 |
| Backbone | DinoV2 ViT-Large |
| Head | DPT (Dense Prediction Transformer) |
| Parameters | 0.35B |
| Input Size | 518x518 |
| Output | Metric Depth Map |
| 指标 | 数值 |
|---|---|
| 推理时间 | ~42s (演示,含CPU回退) |
| NPU显存占用 | ~1.1GB (演示) |
| 模型大小 | ~1.3 GB |
torch>=2.0.0
torch_npu>=2.0.0
numpy>=1.21.0
pillow>=9.0.0
transformers>=4.30.0cd /workspace/agent1/DA3METRIC-LARGE-ascend
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simplecd /workspace/agent1/DA3METRIC-LARGE-ascend
python inference.py --device npu:0 --show_npu_memory--model_path: 模型路径,默认 /workspace/agent2/depth-anything/DA3METRIC-LARGE--device: 运行设备,默认 npu:0--show_npu_memory: 显示NPU显存使用情况import torch
device = "npu:0"
batch_size = 1
channels = 3
height = 518
width = 518
input_image = torch.randn(batch_size, channels, height, width, dtype=torch.float32).to(device)
depth_map = model(input_image)[设备] npu:0
NPU设备数量: 1
设备 0: Ascend910B2
[模型] DA3METRIC-LARGE
[任务] 单目度量深度估计 (Monocular Metric Depth Estimation)
[架构] Depth Anything 3 (ViT-Large + DPT)
[类型] 深度估计模型
[模型配置]
Model Name: da3metric-large
Task: 单目度量深度估计
Backbone: DinoV2 ViT-Large
Parameters: 0.35B
Head: DPT (Dense Prediction Transformer)
Input Size: 518x518
Output: Metric Depth Map
[模型文件]
model.safetensors: 1274.81 MB
[构建测试输入]
Batch Size: 1
Channels: 3
Height: 518
Width: 518
[输入张量形状]
Input Image: (1, 3, 518, 518)
运行DA3METRIC深度估计推理演示...
======================================================================
加载模型到NPU...
======================================================================
======================================================================
前向传播...
======================================================================
======================================================================
NPU 显存状态
======================================================================
[NPU显存] 已分配=1.1425GB | 缓存=1.3555GB | 峰值=1.1672GB
======================================================================
NPU 信息 (npu-smi info)
======================================================================
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 102.0 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 4877 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1178258 | python | 1508 |
+===========================+===============+====================================================+
======================================================================
输出摘要
======================================================================
模型: DA3METRIC-LARGE
任务: 单目度量深度估计
输入形状: torch.Size([1, 3, 518, 518])
深度图形状: torch.Size([1, 1, 37, 37])
深度值范围: [-0.0360, -0.0169]
总耗时: 42.2441s
输出 finite: True
深度统计:
均值: -0.0282
标准差: 0.0027完整模型使用 depth-anything-3:
pip install depth-anything-3然后使用:
import torch
from depth_anything_3.api import DepthAnything3
model = DepthAnything3.from_pretrained("depth-anything/da3metric-large")
model = model.to(device='npu')
model.eval()
images = ["image1.jpg", "image2.jpg"]
prediction = model.inference(
images,
export_dir="output",
export_format="glb"
)
print(prediction.depth.shape) # Depth maps: [N, H, W]
print(prediction.conf.shape) # Confidence maps输入图像 (518x518 RGB)
|
Patch Embedding (14x14)
|
DinoV2 ViT-L Encoder (24层)
|
多尺度特征
|
DPT Head
|
度量深度图