冬
gcw_IDzXRVNw/DA3METRIC-LARGE-ascend
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

DA3METRIC-LARGE-ascend

Depth Anything 3 度量深度估计模型适配昇腾NPU版本。

模型简介

  • 基础模型: depth-anything/DA3METRIC-LARGE
  • 任务: 单目度量深度估计 (Monocular Metric Depth Estimation)
  • 架构: Depth Anything 3 (ViT-Large + DPT)
  • 类型: 深度估计模型
  • 开发公司: ByteDance Seed Team

模型特点

  • Depth Anything 3 度量深度估计模型
  • 基于 DinoV2 ViT-Large 骨干网络
  • 支持单目度量深度估计
  • 支持天空分割
  • 0.35B 参数

模型配置

参数值
Model Nameda3metric-large
Task单目度量深度估计
BackboneDinoV2 ViT-Large
HeadDPT (Dense Prediction Transformer)
Parameters0.35B
Input Size518x518
OutputMetric 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.0

分步推理流程

1. 安装依赖

cd /workspace/agent1/DA3METRIC-LARGE-ascend
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple

2. 运行推理

cd /workspace/agent1/DA3METRIC-LARGE-ascend
python inference.py --device npu:0 --show_npu_memory

3. 参数说明

  • --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
    |
度量深度图

核心组件

  1. Input: RGB图像
  2. Patch Embedding: 图像分块嵌入
  3. DinoV2 Encoder: 24层Vision Transformer
  4. DPT Head: 深度预测头
  5. Output: 度量深度图

应用场景

  • 单目深度估计
  • 3D重建
  • AR/VR
  • 自动驾驶
  • 机器人导航
  • 场景理解

注意事项

  1. 当前演示使用随机张量展示NPU推理流程
  2. 模型约 1.3GB
  3. Transformer层可能回退到CPU
  4. 输入尺寸: 518x518

参考链接

  • DA3METRIC-LARGE 官方模型
  • Depth Anything 3 GitHub
  • Project Page