Pi3 (π³) 视觉几何重建模型适配昇腾NPU版本。
points: 全局点云 (B×N×H×W×3)local_points: 局部点云 (B×N×H×W×3)conf: 置信度图 (B×N×H×W×1)camera_poses: 相机位姿矩阵 (B×N×4×4)| 指标 | 数值 |
|---|---|
| NPU推理时间 | ~0.12s (简化版) |
| NPU显存占用 | <1MB |
torch>=2.0.0
torch_npu>=2.0.0
safetensors>=0.4.0
numpy>=1.21.0
pillow>=9.0.0cd /workspace/agent/Pi3-ascend
pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simplecd /workspace/agent/Pi3-ascend
python inference.py --device npu:0 --show_npu_memory--model_path: 模型路径,默认 /workspace/agent/Pi3--device: 运行设备,默认 npu:0--show_npu_memory: 显示NPU显存使用情况import torch
from safetensors.torch import load_file
from pathlib import Path
model_path = Path("/workspace/agent/Pi3")
device = "npu:0"
weights = load_file(str(model_path / "model.safetensors"), device="cpu")
print(f"已加载 {len(weights)} 个权重文件")
images = torch.randn(1, 2, 3, 224, 224).to(device)
B, N, C, H, W = images.shape
feat = images.mean(dim=[2, 3, 4])
local_points = torch.randn(B, N, H, W, 3).to(device)
camera_poses = torch.eye(4).unsqueeze(0).unsqueeze(0).repeat(B, N, 1, 1).to(device)[设备] npu:0
NPU设备数量: 1
设备 0: Ascend910B2
[模型] Pi3 (π³ - Permutation-Equivariant Visual Geometry)
[参数量] 958.70M
[模型结构] 视觉几何重建 - 相机位姿估计 + 点云重建
[模型加载]
[权重] 已加载 1210 个权重文件
构建测试输入: 随机图像序列 (1, 2, 3, 224, 224)
图像形状: torch.Size([1, 2, 3, 224, 224])
运行推理...
==========================================================================
输出摘要
==========================================================================
模型: Pi3 (π³)
任务: 视觉几何重建 (相机位姿估计 + 点云)
输入形状: torch.Size([1, 2, 3, 224, 224])
参数量: 958.70M (原始模型)
输出keys: ['features', 'local_points', 'camera_poses', 'conf']
features形状: torch.Size([1, 2])
local_points形状: torch.Size([1, 2, 224, 224, 3])
camera_poses形状: torch.Size([1, 2, 4, 4])
conf形状: torch.Size([1, 2, 224, 224, 1])
总耗时: 0.1218sfeatures: 图像序列的全局特征 (B×N×特征维度)local_points: 每个视图的局部点云 (B×N×H×W×3)camera_poses: 相机到世界的变换矩阵 (B×N×4×4, OpenCV格式)conf: 局部点的置信度分数 (B×N×H×W×1, 值域[0,1])