您的位置:首页 > 科技 > IT业 > 湛江网站建设皆选小罗24专业_小企业网站建设哪家便宜_优化营商环境存在问题及整改措施_推广软文发稿

湛江网站建设皆选小罗24专业_小企业网站建设哪家便宜_优化营商环境存在问题及整改措施_推广软文发稿

2025/3/31 17:00:35 来源:https://blog.csdn.net/NF_ALONG/article/details/146551124  浏览:    关键词:湛江网站建设皆选小罗24专业_小企业网站建设哪家便宜_优化营商环境存在问题及整改措施_推广软文发稿
湛江网站建设皆选小罗24专业_小企业网站建设哪家便宜_优化营商环境存在问题及整改措施_推广软文发稿

概述

UIE(Universal Information Extraction):Yaojie Lu等人在ACL-2022中提出了通用信息抽取统一框架UIE。

该框架实现了实体抽取、关系抽取、事件抽取、情感分析等任务的统一建模,并使得不同任务间具备良好的迁移和泛化能力。

为了方便大家使用UIE的强大能力,PaddleNLP借鉴该论文的方法,基于ERNIE 3.0知识增强预训练模型,训练并开源了首个中文通用信息抽取模型UIE。

该模型可以支持不限定行业领域和抽取目标的关键信息抽取,实现零样本快速冷启动,并具备优秀的小样本微调能力,快速适配特定的抽取目标。
在这里插入图片描述
在这里插入图片描述

环境

创建conda环境

conda create --name paddleNlp python=3.8 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

安装Paddle

pip3 install paddlepaddle==2.6.2
pip3 install paddlenlp==2.6.1
pip3 install paddleocr==2.6.1.3

OCR识别

编写程序

import time
start_time = time.time()import argparseparser = argparse.ArgumentParser()
parser.add_argument("--image_path", required=True, help="输入图片路径")
args = parser.parse_args()import paddlenlp
import paddleocr
from pprint import pprint
from paddlenlp import Taskflowprint(paddlenlp.__version__)
print(paddleocr.__version__)schema = ["交易日期", "收款账号","收款开户行","收款人", "付款账号","付款开户行","业务类型","交易流水","业务编号","客户编号","交易金额(小写)","交易金额(大写)","交易摘要","附言","回单编号"]
ie = Taskflow("information_extraction", schema=schema, model="uie-x-base")result = ie({"doc": args.image_path})
pprint(result)end_time = time.time()
print(f"程序运行时间:{end_time - start_time:.2f}秒")

说明:

  1. 添加了argparse模块来处理命令行参数,使用–image_path来接收图片路径
  2. 使用time模块计算程序总运行时间,从脚本启动开始到所有处理完成结束
  3. 在程序最后输出运行时间(保留两位小数)

执行程序

识别下面的图片:
在这里插入图片描述

python3 image_nlp.py --image_path 20250306-152918.jpg

结果输出:

$ python3 image_nlp.py --image_path 20250306-152918.jpg 
/home/super/miniconda3/envs/paddleNlp/lib/python3.8/site-packages/_distutils_hack/__init__.py:31: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.ymlwarnings.warn(
2.8.1.post
2.6.1.3
[2025-03-27 10:39:19,056] [    INFO] - We are using <class 'paddlenlp.transformers.ernie_layout.tokenizer.ErnieLayoutTokenizer'> to load '/home/super/.paddlenlp/taskflow/information_extraction/uie-x-base'.
[{'业务类型': [{'bbox': [[405, 89, 541, 107]],'end': 56,'probability': 0.9131308053430871,'start': 46,'text': '汇入汇款(网银互联)'}],'业务编号': [{'bbox': [[95, 107, 197, 124]],'end': 72,'probability': 0.9995382261303227,'start': 61,'text': '11001640576'}],'交易摘要': [{'bbox': [[51, 145, 68, 161]],'end': 104,'probability': 0.8831240753625877,'start': 102,'text': '收款'}],'交易日期': [{'bbox': [[102, 89, 217, 107]],'end': 41,'probability': 0.9990176840332587,'start': 30,'text': '2024年12月30日'}],'交易流水': [{'bbox': [[383, 108, 515, 126]],'end': 92,'probability': 0.9663297915660252,'start': 77,'text': 'C01471M00201xxx'}],'交易金额(大写)': [{'bbox': [[170, 236, 343, 254]],'end': 246,'probability': 0.9744215604050304,'start': 233,'text': '人民币壹万陆仟陆佰伍拾元整'}],'交易金额(小写)': [{'bbox': [[140, 219, 249, 236], [51, 236, 343, 254]],'end': 246,'probability': 0.31854000882093914,'start': 213,'text': 'CNY16650.00交易金额(大写):人民币壹万陆仟陆佰伍拾元整'}],'付款开户行': [{'bbox': [[134, 200, 273, 218]],'end': 204,'probability': 0.987515932169643,'start': 194,'text': '中国银行汕头谷饶支行'}],'付款账号': [{'bbox': [[95, 180, 204, 199]],'end': 171,'probability': 0.9977437211903961,'start': 159,'text': '641858106xxx'}],'回单编号': [{'bbox': [[330, 351, 447, 368]],'end': 299,'probability': 0.9723847994996504,'start': 286,'text': '816B361444971'}],'收款人': [{'bbox': [[410, 145, 575, 162]],'end': 138,'probability': 0.9709061638304917,'start': 126,'text': '广州xx电子商务有限公司'}],'收款开户行': [{'bbox': [[134, 162, 273, 180]],'end': 154,'probability': 0.9324191178090935,'start': 144,'text': '广东自贸试验区南沙分'}],'收款账号': [{'bbox': [[95, 180, 204, 199]],'end': 171,'probability': 0.9940871034103509,'start': 159,'text': '641858106xxx'}],'附言': [{'bbox': [[51, 145, 68, 161]],'end': 104,'probability': 0.9225480574774565,'start': 102,'text': '收款'}]}]
程序运行时间:30.91秒

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com