本文档记录 DLASeg 表格结构识别模型在昇腾 NPU (Ascend 910B3) 上的迁移适配与精度验证结果。
该模型基于 DLA34 (Deep Layer Aggregation) 骨干网络和 CenterNet 检测头,用于识别表格中的单元格结构(行/列分割),输出包括热力图(hm)、中心点偏移(reg)等。
相关获取地址:
参考文档:
| 组件 | 版本 |
|---|---|
CANN | 8.5.1 |
torch | 2.8.0 |
torch_npu | 2.8.0.post4 |
modelscope | 1.37.0 |
opencv-python-headless | 4.13.0 |
Ascend 910B3,单卡推理[1, 3, 512, 512] RGB 图像conda create -n cv_dla34_table-structure-recognition_cycle-centernet python=3.10 -y
conda activate cv_dla34_table-structure-recognition_cycle-centernet
pip install torch==2.8.0 torch_npu==2.8.0.post4 torchvision==0.23.0 \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.com
pip install modelscope opencv-python-headless numpy \
sortedcontainers simplejson addict datasets pyarrow Pillow \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.commodelscope download --model damo/cv_dla34_table-structure-recognition_cycle-centernet \
--local_dir ./cv_dla34_table-structure-recognition_cycle-centernetpython inference.py --image table.jpg --device npufrom inference import run_inference
result = run_inference("table.jpg", device="npu")
print(f"耗时: {result['time_ms']:.1f}ms")python evaluate.py验证结果:
测试条件:input [1, 3, 512, 512]。
| 指标 | CPU | NPU (Ascend 910B3) |
|---|---|---|
| 推理耗时 | 1894 ms | 20 ms |
| 加速比 | — | 94x |
对比 CPU (PyTorch) 与 NPU (torch_npu) 在相同随机输入下模型输出热力图 (hm) 的鲁棒平均相对误差(|value| > 0.01)。
| 指标 | 数值 |
|---|---|
| 鲁棒平均相对误差 | 0.0137% |
| 精度要求 | 平均相对误差 < 1% |
| 精度评测 | 通过 |
pipeline.infer_model 获取 DLASeg 模型,输出包含 hm、v2c、c2v、reg 等多头