青海省建设局网站,做礼品公司网站的费用,网站为什么要进行内容更新吗,网站文章收录慢基于PaddleOCR2.7.0发布WebRest服务测试案例
#WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. #警告#xff1a;这是一个开发服务器。不要在生产部署中使用它。请改用生产WSGI服务器。
输出结果…基于PaddleOCR2.7.0发布WebRest服务测试案例
#WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. #警告这是一个开发服务器。不要在生产部署中使用它。请改用生产WSGI服务器。
输出结果 输出结果
[中华人民共和国,0.9899783730506897,居民身份证,0.9980843663215637,祥证,0.8810203075408936,正,0.9998733997344971,签发机关北京市公安商西城分局,0.9768146872520447,有效期限2004.10.27-2024.10.26,0.9777843952178955,姓名金阳,0.9970041513442993,反,0.8982676267623901,性别女,0.9921286702156067,民族汉,0.7694575190544128,出生1978年10月27日,0.9945864081382751,住址北京市西城区复兴门外大,0.9793714284896851,街999号院11号楼3单元,0.997355043888092,样证502室,0.954838752746582,公民身份号码,0.999056339263916,110102197810272321,0.9936114549636841,头杀刘海波,0.8078877925872803
]postman请求格式
访问地址http://127.0.0.1:5000/ocr post模式 参数image_path
postman 请求格式
Json格式和 image_path{image_path : E:/project/python/OCR/data/sfz.jpg
}安装paddleocr2.7.0 激活环境
conda activate d:\programdata\conda\cwgis
conda deactivate采用pip模式查询包的版本列表情况
pip index versions paddleocrpip install paddleocr2.7.0#兼容性再安装
pip install opencv-python4.4.0.46
pip install click8.1.3
conda install pillow9.0.1
PaddleOCR版本列表情况
C:\Users\hsgpcpip index versions paddleocr
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
paddleocr (2.7.0.2)
Available versions: 2.7.0.2, 2.7.0.1, 2.7.0.0, 2.6.1.3, 2.6.1.2, 2.6.1.1, 2.6.1.0, 2.6.0.3, 2.6.0.2, 2.6.0.1, 2.6, 2.5.0.3, 2.5.0.2, 2.5, 2.4.0.4, 2.4.0.3, 2.4.0.2, 2.4.0.1, 2.4, 2.3.0.2, 2.3.0.1, 2.3, 2.2.0.2, 2.2.0.1, 2.2, 2.0.6, 2.0.5, 2.0.4, 2.0.3, 2.0.2, 2.0.1, 1.1.1, 1.0.1, 1.0.0, 0.0.3.1, 0.0.3, 0.0.2, 0.0.1.1C:\Users\hsgpc测试的发布服务的代码
from flask import Flask, request, jsonify
from paddleocr import PaddleOCR#报错ImportError: cannot import name ParameterSource from click.core
#pip index versions click #查看版本号列表
#随机选择一个版本8.0.0版本安装时提示flask 2.3.2 requires click8.1.3,
#故再次选择安装8.1.3版本 OK
#pip install click8.1.3# need to run only once to download and load model into memory
p PaddleOCR(use_angle_clsTrue, langch) print(__name__) #__main__
app Flask(__name__)#定义 get 方法 /v
app.route(/v, methods[get])
def v():return 1.0.0#定义 post 方法 /ocr
app.route(/ocr, methods[POST])
def ocr():data request.get_json()image_path data[image_path] # 从请求中获取图像路径print(image_path,image_path)#ocr_result PaddleOCR.ocr(image_path, use_gpuFalse) # 调用PaddleOCR模型进行图像识别ocr_result p.ocr(image_path, clsTrue)h_result[]index1for line in ocr_result: for detection in line:tdetection[1][0],str(detection[1][1])h_result.append(t)index1return jsonify(h_result) # 将识别结果以JSON格式返回给客户端if __name__ __main__:app.run()#http://127.0.0.1:5000/v #OK
本blog地址https://blog.csdn.net/hsg77 —the—end—