UFM-Base-980 (UniFlowMatch) 是卡内基梅隆大学开源的统一密集对应模型的高分辨率版本,能够同时处理光流估计和宽基线匹配任务。
本模型是一种端到端训练的 transformer 模型,支持 980x644 高分辨率推理。
| 属性 | 值 |
|---|---|
| 模型类型 | UFM (统一流匹配) |
| Backbone | DINOv2-Large (24层) |
| Encoder 隐藏维度 | 1024 |
| Attention Heads | 16 |
| Patch Size | 14 |
| 推理分辨率 | 980x644 |
| Flow Head | DPT 风格 |
| Uncertainty Head | DPT 风格 |
| Info Sharing | 全局注意力 (12层) |
| 权重格式 | safetensors |
| 总权重数 | 613 |
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| 操作系统 | CentOS 7.6+ / Ubuntu 18.04+ | 支持主流 Linux 发行版 |
| CANN | 5.0.RC2+ | 华为昇腾计算架构 |
| Python | 3.10 / 3.12 | 推荐 3.10+ |
| PyTorch | 2.0.0+ | 推荐 2.10 |
| torch_npu | 与 PyTorch 版本匹配 | 昇腾 PyTorch 扩展 |
| safetensors | >=0.4.0 | 权重加载 |
# 1) 激活已预装 torch / torch_npu 的 conda 环境
conda activate pt2100
# 2) 安装模型依赖(使用华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple \
safetensors torch_npu numpy
# 3) 验证环境
python -c "
import torch, torch_npu
print('torch:', torch.__version__)
print('torch_npu:', torch_npu.__version__)
print('NPU 可用:', torch.npu.is_available())
"# 进入适配目录
cd /workspace/agent1/UFM-Base-980-ascend
# 确认上游权重存在
ls -la /workspace/agent2/infinity1096/UFM-Base-980/# 检查 NPU 设备状态
npu-smi info
# 验证 torch_npu 安装
python -c "import torch; import torch_npu; print('NPU 可用:', torch.npu.is_available())"# 基本用法:默认参数 (NPU:0, 980x644)
python inference.py --device npu:0
# 指定其他分辨率
python inference.py --device npu:0 --height 980 --width 644
# 指定其他 NPU 卡
python inference.py --device npu:1
# CPU 模式(仅在 NPU 不可用时使用)
python inference.py --device cpuconda activate pt2100
cd /workspace/agent1/UFM-Base-980-ascend
python inference.py --device npu:0实际输出:
============================================================
UFM-Base-980 昇腾 NPU 推理 (高分辨率)
============================================================
[Device] npu:0
[Model Path] /workspace/agent2/infinity1096/UFM-Base-980
[Loading] Model weights from safetensors...
Loaded 613 weights
[Creating] Complete UFM model...
Loaded 336 encoder parameters
Loaded 18 flow head parameters
Loaded 18 uncertainty head parameters
Loaded 100 info_sharing parameters
Model created successfully
[Model Loaded] Allocated: 1.50 GB, Reserved: 1.66 GB
[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 | 96.6 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 5187 / 65536 |
+===========================+===============+====================================================+
+---------------------------+---------------+----------------------------------------------------+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1345197 | python | 1818 |
+===========================+===============+====================================================+
[Creating] Dummy image pair (980x644)...
Image1 shape: torch.Size([1, 3, 980, 644])
Image2 shape: torch.Size([1, 3, 980, 644])
[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 | 146.8 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 5513 / 65536 |
+===========================+===============+====================================================+
[Flow Results]
Flow prediction shape: torch.Size([1, 2, 980, 644])
Flow uv components sample:
u (horizontal): [1.07, 1.01, 0.95, 0.89, 0.83]
v (vertical): [0.44, 0.43, 0.41, 0.40, 0.39]
[Uncertainty Results]
Uncertainty prediction shape: torch.Size([1, 1, 980, 644])
Uncertainty sample: [0.098, 0.098, 0.098, 0.098, 0.098]
[Memory After Full Inference] Allocated: 1.48 GB, Reserved: 1.96 GB
[Done]✅ 验证要点:
解决方案:
source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh)npu-smi info 检查设备状态解释:UFM-Base-980 是高分辨率版本,推理分辨率为 980x644,而 UFM-Base 的推理分辨率为 560x420。980 版本可以处理更精细的对应关系。
解释:更高的分辨率可以提供更精确的光流估计,特别是在细节丰富的场景中。UFM-Base-980 特别适合需要高精度对应关系的应用。
UFM-Base-980-ascend/
├── inference.py # 推理脚本(torch_npu 推理)
├── README.md # 本文档
├── requirements.txt # 依赖列表
└── assets/ # 资源占位目录上游权重目录(只读,未被修改):
/workspace/agent2/infinity1096/UFM-Base-980/
├── config.json # 模型配置
├── model.safetensors # 权重 (~1.7GB)
└── README.md # 原始文档# UFM-Base-980 昇腾 NPU 推理环境依赖
# 核心依赖(必须)
torch>=2.0.0
torch_npu
safetensors>=0.4.0
numpy使用方式:
# 激活环境
conda activate pt2100
# 安装依赖(华为云源)
pip install --index-url https://repo.huaweicloud.com/repository/pypi/simple -r requirements.txt