#NPU
本仓库将 HuggingFace 上的 depth-anything/DA3METRIC-LARGE(DA3 Metric Large,ViT-L DINOv2 骨干 + DPT 解码头,0.35B 参数,monocular metric depth 统一深度-射线表征)适配为可在单卡昇腾 Ascend 910(npu:0)上真实运行的 GitCode AI model 仓库。支持 metric depth 与 sky 分割,输入任意 RGB 图像输出 metric 深度图。
model.safetensors 1.27 GB(334,171,394 参数,406 tensors,float32),config.json 定义 da3metric-large(net vitl out_layers [4,11,17,23],head DPT dim_in 1024 features 256 out_channels [256,512,1024,1024])depth_anything_3.model.da3.DepthAnything3Net,MODEL_REGISTRY['da3metric-large'])| 项 | 值 |
|---|---|
| 模型 | DA3METRIC-LARGE(revision main,0.334B params,1.27 GB safetensors) |
| 架构 | DepthAnything3Net(ViT-L DINOv2 24 blocks dim1024 + DPT head 256/512/1024/1024,sky 分支) |
| 任务 | 计算机视觉 - 单目 metric 深度估计 depth-estimation(附加 sky 分割) |
| 输入 | image [B,N,3,H,W] float32,H%14==0 W%14==0(本仓 640x480 -> longest 504 + nearest 14 -> 504x378) |
| 输出 | depth [B,N,H,W] metric depth float32 + sky [B,N,H,W] 0-1 概率 + aux 空 dict |
| 数据契约 | 输入轴 [B,N,3,H,W],输出 [B,N,H,W];预处理 upper_bound_resize 最长边504 + nearest Multiple 14,cv2 INTER_AREA/CUBIC,ImageNet 归一化 mean [0.485,0.456,0.406] std [0.229,0.224,0.225];输出 metric depth 需乘 focal 得真实尺度 |
| 路由 | 计算机视觉 depth-estimation(参考 depth-anything-3 官方 api,验收 depth/sky 数值一致性与性能) |
npu:0 目标设备torch 2.9.0+cpu + torch_npu 2.9.0.post1+gitee7ba04,torchvision,safetensors,omegaconf,addict,einops,numpy<2,pillow,opencv-python-headless/tmp/depth-anything-3/src(需 git clone https://github.com/ByteDance-Seed/depth-anything-3 后将 src 加入 sys.path)git clone https://github.com/ByteDance-Seed/depth-anything-3 /tmp/depth-anything-3
pip install -r requirements.txt
# 模型权重需从 https://huggingface.co/depth-anything/DA3METRIC-LARGE 下载至 /opt/atomgit/adapt-npu-agent/models/DA3METRIC-LARGE/model.safetensorspython inference.py/opt/atomgit/adapt-npu-agent/models/DA3METRIC-LARGE 加载权重,回退 MODEL_DIR 环境变量copy.deepcopy(cpu_model).to("npu:0") 与 tensor.to("npu:0"),日志打印 device/dtype/shape/耗时,前后 torch.npu.synchronize(),无 CPU fallback[STATUS] SUCCESSpython .claude/skills/npu-adapt-skills/scripts/compare_outputs.py --task regression(实际脚本用 depth 通用回归阈值)set(str(p.device) for p in model.parameters()) == {'npu:0'}torch.npu.synchronize(),batch 1assets/agent_workflow.png - 工作流(侦察/下载/加载/NPU/一致性/性能/校验)assets/npu_device_call.png - 设备调用(npu-smi、check_npu、参数与张量 npu:0)assets/model_result.png - 默认推理完整输出(CPU/NPU stats、一致性、性能)atomgit@pod-a94f8701860f4700b161b00e290de466:~$),非手绘

/tmp/depth-anything-3/src,非 pip 包ByteDance Seed 团队 Depth Anything 3 官方实现与权重。