文件最后提交记录最后更新时间
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
适配UVDoc模型 Co-authored-by: socrahow<suzihao4@h-partners.com> # message auto-generated for no-merge-commit merge: !7533 merge uvdoc into master 适配UVDoc模型 Created-by: socrahow1 Commit-by: socrahow1;socrahow Merged-by: ascend-robot Description: ## Motivation 适配UVDoc模型。 ## Modification 适配UVDoc模型。 ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!753327 天前
README.md

UVDoc(OM)-推理指导

概述

从折叠和皱褶页面的照片中恢复文档的原始外观是一个常见的日常问题。原仓实现了一种基于网格的单图像文档形变恢复方法,能够较好的校正照片的畸变。原仓是"UVDoc: Neural Grid-based Document Unwarping"论文的代码实现。

本文介绍了UVDoc模型的部署流程,包括推理环境准备、模型部署、功能验证,旨在帮助用户快速完成模型部署和验证。该模型仅在Atlas 800T A2, Atlas 800I A2上验证过,其他硬件暂未验证。该模型的train、eval暂未适配。

  • 版本说明:
url=https://github.com/tanguymagne/UVDoc.git
commit_id=4c9b82b537057aff2526e6dd118a847cdd072e82

推理环境准备

  • 该模型需要以下插件与驱动
    表 1 版本配套表
配套 版本 环境准备指导
固件与驱动 25.5.2 Pytorch框架推理环境准备
CANN 8.5.0 -
Python 3.11 -
PyTorch 2.1.0 -
Ascend Extension PyTorch 2.1.0.post17 -
硬件 Atlas 800T A2, Atlas 800I A2 -

快速上手

配置opencv环境

apt-get update
apt-get install -y libgl1 libglib2.0-0

配置tesseract环境

评估时需要,若只推理,可不装。

# 该仓在openEuler上支持不佳,需在ubuntu系统上进行安装
apt-get update
apt-get install -y tesseract-ocr tesseract-ocr-eng

配置OM环境

需要下载ais_bench对应的whl包,然后安装。获取地址

pip install aclruntime-0.0.2-cp311-cp311-linux_aarch64.whl
pip install ais_bench-0.0.2-py3-none-any.whl

获取源码

git clone https://gitcode.com/Ascend/ModelZoo-PyTorch.git
cd ModelZoo-PyTorch/ACL_PyTorch/built-in/ocr/UVDoc
git clone https://gitee.com/Ronnie_zheng/MagicONNX.git
cd MagicONNX
git apply ../diff_onnx.patch
pip install -e .
cd ..

git clone https://github.com/tanguymagne/UVDoc.git
cd UVDoc
git apply ../diff_uvdoc.patch
cp ../my_uvdocBenchMark_eval.py .
cd ..
pip install -r requirements.txt
# 若需要评估精度,可安装以下依赖,若仅推理无需安装
pip install -r requirements_eval.txt

数据集下载

cd UVDoc/data
wget https://igl.ethz.ch/projects/uvdoc/UVDoc_benchmark.zip
unzip UVDoc_benchmark.zip
cd ..

pkl转om

1、导出onnx模型

python ../pkl2onnx.py --ckpt-path ./model/best_model.pkl --output-path ./model/best_model.onnx

参数说明
--ckpt-path:pkl权重路径。
--output-path:生成onnx权重保存路径。

2、导出om模型 参照ATC工具指导,执行npu-smi info查看芯片名称,并赋值为${soc_version},执行ATC命令,生成UVDoc的om模型,文件名为best_model.om。

source /usr/local/Ascend/ascend-toolkit/set_env.sh
atc --framework 5 --model ./model/best_model.onnx --output ./model/best_model --soc_version Ascend${soc_version} --input_format NCHW

环境变量

# 一级流水优化
export TASK_QUEUE_ENABLE=1
# combind标志,用于优化两个非连续算子组合类场景
export COMBIND_ENABLE=1
# CPU绑核
export CPU_AFFINITY_CONF=1

执行推理

运行推理脚本

ASCEND_RT_VISIBLE_DEVICES=0 python uvdocBenchmark_pred.py --ckpt-path ./model/best_model.om --uvdoc-path ./data/UVDoc_benchmark/

参数说明
ASCEND_RT_VISIBLE_DEVICES:执行推理的NPU卡,脚本默认在0卡执行,可通过该参数修改执行的卡(仅支持单卡推理)。
--ckpt-path:om权重路径。
--uvdoc-path:UVDoc_benchmark数据集路径。

性能数据

机器 数据集 文件数量 编码格式 纯推理性能 E2E性能
Atlas 800T A2 UVDoc_benchmark 50 jpg 50fps 10fps

精度评估

精度评估需要安装tesseract环境 运行评估脚本(指标计算方式与官方不一致,不支持与官方指标进行比较)

python my_uvdocBenchmark_eval.py --uvdoc-path ./data/UVDoc_benchmark/ --pred-path ./model/output_uvdoc --pred-type uwp_texture --verbose

参数说明
--uvdoc-path:UVDoc_benchmark数据集路径。
--pred-path:UVDoc_benchmark数据集推理结果保存路径。
--pred-type:比较推理结果的类型,仅支持uwp_texture和uwp_img。
--verbose:打印进度信息。

精度数据

数据集 硬件 测试类型 MS-SSIM
UVDoc_benchmark npu uwp_texture 0.68
UVDoc_benchmark npu uwp_img 0.59
UVDoc_benchmark cpu uwp_texture 0.68
UVDoc_benchmark cpu uwp_img 0.59

指标说明
MS-SSIM (Multi Scale Structural Similarity Index Measure) 多尺度结构相似性。