模型名称: infinity1096/UFM-Base
模型链接: HuggingFace
模型描述: UFM (UniFlowMatch) 是一个简单的端到端训练 Transformer 模型,直接回归像素位移场,同时适用于光学流和宽基线匹配任务。
模型架构: DINOv2-large (ViT-L/14) Encoder + Multi-View Global Attention + DPT Prediction Head + FlowAdaptor
参数规模: ~428M
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| uniflowmatch | >= 0.1.0 | UFM 模型源码 |
| uniception | >= 0.1.7 | UniCeption 基础组件 |
| timm | >= 1.0.0 | DINOv2 编码器依赖 |
| opencv-python-headless | >= 4.5.0 | 图像加载 |
| flow_vis | >= 0.1.0 | Flow 可视化 |
| numpy | >= 1.26.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch_npu uniflowmatch uniception timm opencv-python-headless flow_vis numpynpu-smi info
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"huggingface-cli download infinity1096/UFM-Base --local-dir ./UFM-Base# UFM 模型通过 inference.py 直接运行,无需单独启动服务
# 单张推理
python inference.py --model-path /path/to/modelpython inference.py --model-path ./UFM-Base/ufm_560_base.pt
python inference.py --model-path ./UFM-Base/ufm_560_base.pt --source img1.png --target img2.png| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --source | str | 示例图 | 源图像路径 |
| --target | str | 示例图 | 目标图像路径 |
| --device | int | 0 | NPU 设备 ID |
[设备] Ascend NPU: Ascend910_9362
[加载] 模型加载完成,参数量: 428,253,187
[输入] 源图像: (580, 1080, 3)
[输入] 目标图像: (580, 1080, 3)
[输出] Flow shape: (2, 580, 1080)
[输出] Flow range: [-127.3087, 46.7314], mean: -54.7268
[输出] Mask shape: (580, 1080)
[输出] Mask range: [0.0000, 1.0000], mean: 0.7502
[耗时] 推理耗时: 0.42s
[状态] SUCCESSpython inference.py --model-path ./UFM-Base/ufm_560_base.pt输出:
[设备] Ascend NPU: Ascend910_9362
[加载] 模型加载完成,参数量: 428,253,187
[输入] 使用默认示例图像
[输入] 源图像: (580, 1080, 3)
[输入] 目标图像: (580, 1080, 3)
[输出] Flow shape: (2, 580, 1080)
[输出] Flow range: [-127.3087, 46.7314], mean: -54.7268
[输出] Mask shape: (580, 1080)
[输出] Mask range: [0.0000, 1.0000], mean: 0.7502
[耗时] 推理耗时: 0.42s
[状态] SUCCESS


| 指标 | 结果 | 说明 |
|---|---|---|
| Flow 输出范围 | [-127.31, 46.73] | 像素位移范围 |
| Covisibility 均值 | 0.7502 | 共视区域置信度 |
| 推理耗时 (NPU) | 0.42s | 单张 580x1080 图像对 |
| 参数量 | 428.3M | 模型规模 |