模型:
siyan824/profusion_pr(PROFusion,ICRA 2026)—— 相机跟踪 + 稠密重建 系统的 位姿回归模块。 本文档给出在 昇腾 Ascend910 NPU 上运行该模型的完整方案(torch_npu 原生推理 + OpenAI 风格 HTTP 服务)。
PROFusion 面向 RGB-D 相机在剧烈运动 / 大视角变化等不稳定运动下仍然鲁棒地重建场景。本仓库为其 pose regression module 权重:
ref + 源帧 src,各含 RGB 图、深度图、相机内参)src 帧相对 ref 帧的 4x4 相机位姿矩阵(旋转 + 平移,metric 米尺度)| 项 | 值 |
|---|---|
| 架构 | PROFusion(DUSt3R / SLAM3R 系多视图视觉 Transformer) |
| 组件 | PatchEmbed(16x16) + 24×编码器(ViT Block, RoPE100) + 12×多视图双向解码器 + PoseHead |
| 参数量 | 约 0.54B(fp32 权重约 2.16 GB) |
| 上游 | 官方代码 https://github.com/siyandong/PROFusion ;权重 https://huggingface.co/siyan824/profusion_pr |
| 许可证 | CC BY-NC-SA 4.0(非商用) |
为什么不用 vLLM-Ascend?
PROFusion 不是自回归语言模型:无语 tokenizer、无 token 序列自回归解码,输出是 4×4 位姿矩阵而非 token。vLLM/vLLM-Ascend 的注册表并不包含此类多视图位姿回归架构,因此本仓库采用 torch_npu 原生前向推理 + FastAPI 服务化的路线。
| 软件 | 版本 |
|---|---|
| 昇腾驱动 | Ascend910(CANN 8.x) |
| Python | 3.11 |
| torch + torch_npu | 2.9.0 + 2.9.0.post1 |
| numpy | >=1.26 |
| opencv-python | 4.x(可选,解码图像用) |
| fastapi / uvicorn | 服务化需要 |
| safetensors | 读 model.safetensors |
安装:
source /usr/local/Ascend/ascend-toolkit/set_env.sh # 昇腾 CANN 环境
pip install torch==2.9.0 torch_npu==2.9.0.post1 \
numpy opencv-python safetensors fastapi uvicorn tqdm本仓库已本地化官方
pose_regression/包(CC BY-NC-SA 4.0),仅两处 NPU 兼容改动:MyNvtxRange(原 torch.cuda.nvtx)改为 no-op;位姿头 SVD 正交化移至 CPU。图像/深度前处理不依赖 PIL。
profusion_pr/
├── inference.py # NPU 推理脚本(必选)
├── server.py # OpenAI 风格 HTTP 服务(可选)
├── README.md # 本文档
├── requirements.txt # 依赖清单
├── pose_regression/ # 官方源码本地化(CC BY-NC-SA 4.0)
└── assets/ # 截图素材
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png将权重大文件放到 weights/model/(profusion_pr.pth 或 model.safetensors 任一个即可,未入库):
mkdir -p weights/model
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download siyan824/profusion_pr --local-dir weights/modelpython inference.py --model_path ./weights/model --device npu:0实测输出(Ascend910,npu:0,missing=0 unexpected=0):
{
"model": "siyan824/profusion_pr",
"device": "npu:0",
"pose_4x4": [
[0.99999201, 0.00233500, -0.00332200, 0.016577],
[-0.00237900, 0.999906, -0.01345900, 0.026829],
[0.00329000, 0.013468, 0.999904, -0.313682],
[0, 0, 0, 1]
],
"translation_m": [0.016577, 0.026823, -0.313682],
"rotation": [ ... ]
}views.json(第 1 帧 = ref、第 2 帧 = src;image/depth 可为文件路径或内联数组):
{"views": [
{"image": "ref.png", "depth": "ref_depth.png",
"intrinsics": [[640,0,320],[0,640,240],[0,0,1]]},
{"image": "src.png", "depth": "src_depth.png",
"intrinsics": [[640,0,320],[0,640,240],[0,0,1]]}
]}python inference.py --model_path ./weights/model --input_file views.json --device npu:0启动服务(启动即加载模型到 NPU,首个请求无冷启动):
python server.py --model_path ./weights/model --device npu:0 --port 8100模型信息 / 健康检查:
curl http://127.0.0.1:8100/v1/models两帧位姿估计(OpenAI chat/completions 接口):
curl -s http://127.0.0.1:8100/v1/chat/completions -H 'Content-Type: application/json' -d '{
"model": "siyan824/profusion_pr",
"messages": [{"role":"user","content":{
"type":"rgbd_views",
"frames": [
{"image_uri":"/path/ref.png","depth_uri":"/path/ref_d.png",
"intrinsics":[[640,0,320],[0,640,240],[0,0,1]]},
{"image_uri":"/path/src.png","depth_uri":"/path/src_d.png",
"intrinsics":[[640,0,320],[0,640,240],[0,0,1]]}
]}}]
}'返回 choices[0].message.content 为 JSON(含 pose_4x4 / translation_m / rotation)。
| 项 | 说明 |
|---|---|
| 输入分辨率 | 内部用 224x224(patch=16 的整数倍),自定义输入自动缩放即可 |
| SVD | 位姿头 9D→SO(3) 的 torch.svd 在昇腾存在算子编译问题,改在 CPU 执行(3x3 极小矩阵,不影响性能) |
| RoPE | 官方 cuRoPE2D(CUDA kernel)不可用,自动走纯 PyTorch 慢版(缓存 cos/sin 表) |
| 显存 | fp32 权重约 2.2 GiB + 激活,Ascend910 单卡轻松运行 |
| 深度单位 | 米(metric 尺度);若其他单位请先归一 |
(assets/ 下三个截图,由使用者自取):
agent_workflow.png:Agent 适配工作流npu_device_call.png:NPU 设备调用日志model_result.png:模型最终推理结果截图