安装PaddleOCR-2.7.0版本-笔记

安装PaddleOCR-2.7.0版本-笔记

先安装conda和python版本
本机安装的conda 22.9.0
python2.9.12
paddle2.4.2
paddlepaddle-gpu==2.4.2 cuda10.2
安装完后,测试生成的结果如下所示:
在这里插入图片描述
一、第一步先激活环境
conda activate base

conda activate base

二、第二步安装PaddleOCR-2.7.0版本
当前默认版本是paddleocr-2.7.0.2
pip install paddleocr
或者指定版本
pip install paddleocr==2.7.0

安装最新版本:pip install paddleocr

pip install paddleocr

安装指定版本:pip install paddleocr==2.7.0

pip install paddleocr==2.7.0

当前opencv-python版本为4.5.4.60->其它版本如先切换到:4.5.4.58,然后也可以切换回来60版
重新安装opencv-python版本pip install opencv-python==4.5.4.58
报错信息需要

#运行报错信息
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
(base) D:\ProgramData\Anaconda3>pip install opencv-python==4.5.4.58
Collecting opencv-python==4.5.4.58Downloading opencv_python-4.5.4.58-cp39-cp39-win_amd64.whl (35.1 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 35.1/35.1 MB 107.1 kB/s eta 0:00:00
Requirement already satisfied: numpy>=1.19.3 in d:\programdata\anaconda3\lib\site-packages (from opencv-python==4.5.4.58) (1.21.5)
Installing collected packages: opencv-pythonAttempting uninstall: opencv-pythonFound existing installation: opencv-python 4.5.4.60Uninstalling opencv-python-4.5.4.60:Successfully uninstalled opencv-python-4.5.4.60
Successfully installed opencv-python-4.5.4.58

三、PaddleOCR-2.7.0版本安装详细情况

(base) D:\ProgramData\Anaconda3>pip install paddleocr
Collecting paddleocrDownloading paddleocr-2.7.0.2-py3-none-any.whl (466 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 466.1/466.1 kB 213.0 kB/s eta 0:00:00
Requirement already satisfied: numpy in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (1.21.5)
Requirement already satisfied: cython in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (0.29.32)
Requirement already satisfied: fonttools>=4.24.0 in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (4.25.0)
Requirement already satisfied: lxml in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (4.9.1)
Requirement already satisfied: scikit-image in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (0.19.2)
Collecting fire>=0.3.0Downloading fire-0.5.0.tar.gz (88 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.3/88.3 kB 277.7 kB/s eta 0:00:00Preparing metadata (setup.py) ... done
Collecting PyMuPDF<1.21.0Downloading PyMuPDF-1.20.2-cp39-cp39-win_amd64.whl (6.6 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.6/6.6 MB 114.1 kB/s eta 0:00:00
Requirement already satisfied: Pillow in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (9.2.0)
Collecting pdf2docxDownloading pdf2docx-0.5.6-py3-none-any.whl (148 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.4/148.4 kB 53.9 kB/s eta 0:00:00
Collecting pyclipperDownloading pyclipper-1.3.0.post4-cp39-cp39-win_amd64.whl (95 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 95.1/95.1 kB 74.4 kB/s eta 0:00:00
Collecting imgaugDownloading imgaug-0.4.0-py2.py3-none-any.whl (948 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 948.0/948.0 kB 171.5 kB/s eta 0:00:00
Collecting premailerDownloading premailer-3.10.0-py2.py3-none-any.whl (19 kB)
Requirement already satisfied: tqdm in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (4.64.1)
Collecting python-docxDownloading python-docx-0.8.11.tar.gz (5.6 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/5.6 MB 99.6 kB/s eta 0:00:00Preparing metadata (setup.py) ... done
Requirement already satisfied: visualdl in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (2.5.3)
Collecting lmdbDownloading lmdb-1.4.1-cp39-cp39-win_amd64.whl (105 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 105.9/105.9 kB 73.7 kB/s eta 0:00:00
Collecting attrdictDownloading attrdict-2.0.1-py2.py3-none-any.whl (9.9 kB)
Requirement already satisfied: openpyxl in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (3.0.10)
Requirement already satisfied: opencv-python<=4.6.0.66 in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (4.5.4.60)
Collecting rapidfuzzDownloading rapidfuzz-3.2.0-cp39-cp39-win_amd64.whl (1.8 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 63.9 kB/s eta 0:00:00
Collecting opencv-contrib-python<=4.6.0.66Downloading opencv_contrib_python-4.6.0.66-cp36-abi3-win_amd64.whl (42.5 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.5/42.5 MB 93.9 kB/s eta 0:00:00
Collecting shapelyDownloading shapely-2.0.1-cp39-cp39-win_amd64.whl (1.4 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 189.8 kB/s eta 0:00:00
Requirement already satisfied: beautifulsoup4 in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (4.11.1)
Requirement already satisfied: six in d:\programdata\anaconda3\lib\site-packages (from fire>=0.3.0->paddleocr) (1.16.0)
Collecting termcolorDownloading termcolor-2.3.0-py3-none-any.whl (6.9 kB)
Requirement already satisfied: soupsieve>1.2 in d:\programdata\anaconda3\lib\site-packages (from beautifulsoup4->paddleocr) (2.3.1)
Requirement already satisfied: scipy in d:\programdata\anaconda3\lib\site-packages (from imgaug->paddleocr) (1.9.1)
Requirement already satisfied: matplotlib in d:\programdata\anaconda3\lib\site-packages (from imgaug->paddleocr) (3.5.2)
Requirement already satisfied: imageio in d:\programdata\anaconda3\lib\site-packages (from imgaug->paddleocr) (2.19.3)
Requirement already satisfied: PyWavelets>=1.1.1 in d:\programdata\anaconda3\lib\site-packages (from scikit-image->paddleocr) (1.3.0)
Requirement already satisfied: packaging>=20.0 in d:\programdata\anaconda3\lib\site-packages (from scikit-image->paddleocr) (21.3)
Requirement already satisfied: networkx>=2.2 in d:\programdata\anaconda3\lib\site-packages (from scikit-image->paddleocr) (2.8.4)
Requirement already satisfied: tifffile>=2019.7.26 in d:\programdata\anaconda3\lib\site-packages (from scikit-image->paddleocr) (2021.7.2)
Requirement already satisfied: et_xmlfile in d:\programdata\anaconda3\lib\site-packages (from openpyxl->paddleocr) (1.1.0)
Requirement already satisfied: requests in d:\programdata\anaconda3\lib\site-packages (from premailer->paddleocr) (2.28.1)
Requirement already satisfied: cssselect in d:\programdata\anaconda3\lib\site-packages (from premailer->paddleocr) (1.1.0)
Collecting cssutilsDownloading cssutils-2.7.1-py3-none-any.whl (399 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 399.7/399.7 kB 154.8 kB/s eta 0:00:00
Collecting cachetoolsDownloading cachetools-5.3.1-py3-none-any.whl (9.3 kB)
Requirement already satisfied: colorama in d:\programdata\anaconda3\lib\site-packages (from tqdm->paddleocr) (0.4.5)
Requirement already satisfied: psutil in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (5.9.0)
Requirement already satisfied: rarfile in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (4.0)
Requirement already satisfied: pandas in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (1.4.4)
Requirement already satisfied: Flask-Babel>=3.0.0 in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (3.1.0)
Requirement already satisfied: flask>=1.1.1 in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (2.3.2)
Requirement already satisfied: bce-python-sdk in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (0.8.87)
Requirement already satisfied: protobuf>=3.20.0 in d:\programdata\anaconda3\lib\site-packages (from visualdl->paddleocr) (3.20.0)
Requirement already satisfied: importlib-metadata>=3.6.0 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (4.11.3)
Requirement already satisfied: Jinja2>=3.1.2 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (3.1.2)
Requirement already satisfied: blinker>=1.6.2 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (1.6.2)
Requirement already satisfied: click>=8.1.3 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (8.1.6)
Requirement already satisfied: Werkzeug>=2.3.3 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (2.3.6)
Requirement already satisfied: itsdangerous>=2.1.2 in d:\programdata\anaconda3\lib\site-packages (from flask>=1.1.1->visualdl->paddleocr) (2.1.2)
Requirement already satisfied: Babel>=2.12 in d:\programdata\anaconda3\lib\site-packages (from Flask-Babel>=3.0.0->visualdl->paddleocr) (2.12.1)
Requirement already satisfied: pytz>=2022.7 in d:\programdata\anaconda3\lib\site-packages (from Flask-Babel>=3.0.0->visualdl->paddleocr) (2023.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in d:\programdata\anaconda3\lib\site-packages (from packaging>=20.0->scikit-image->paddleocr) (3.0.9)
Requirement already satisfied: future>=0.6.0 in d:\programdata\anaconda3\lib\site-packages (from bce-python-sdk->visualdl->paddleocr) (0.18.2)
Requirement already satisfied: pycryptodome>=3.8.0 in d:\programdata\anaconda3\lib\site-packages (from bce-python-sdk->visualdl->paddleocr) (3.18.0)
Requirement already satisfied: cycler>=0.10 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->imgaug->paddleocr) (0.11.0)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->imgaug->paddleocr) (1.4.2)
Requirement already satisfied: python-dateutil>=2.7 in d:\programdata\anaconda3\lib\site-packages (from matplotlib->imgaug->paddleocr) (2.8.2)
Requirement already satisfied: idna<4,>=2.5 in d:\programdata\anaconda3\lib\site-packages (from requests->premailer->paddleocr) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in d:\programdata\anaconda3\lib\site-packages (from requests->premailer->paddleocr) (2022.9.14)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in d:\programdata\anaconda3\lib\site-packages (from requests->premailer->paddleocr) (1.26.11)
Requirement already satisfied: charset-normalizer<3,>=2 in d:\programdata\anaconda3\lib\site-packages (from requests->premailer->paddleocr) (2.0.4)
Requirement already satisfied: zipp>=0.5 in d:\programdata\anaconda3\lib\site-packages (from importlib-metadata>=3.6.0->flask>=1.1.1->visualdl->paddleocr) (3.8.0)
Requirement already satisfied: MarkupSafe>=2.0 in d:\programdata\anaconda3\lib\site-packages (from Jinja2>=3.1.2->flask>=1.1.1->visualdl->paddleocr) (2.1.3)
Building wheels for collected packages: fire, python-docxBuilding wheel for fire (setup.py) ... doneCreated wheel for fire: filename=fire-0.5.0-py2.py3-none-any.whl size=116933 sha256=990b480b38515263ad3ecb8ff990b5de7a6878ec67a34c25a531b5352db1c6faStored in directory: c:\users\hsgpc\appdata\local\pip\cache\wheels\f7\f1\89\b9ea2bf8f80ec027a88fef1d354b3816b4d3d29530988972f6Building wheel for python-docx (setup.py) ... doneCreated wheel for python-docx: filename=python_docx-0.8.11-py3-none-any.whl size=184489 sha256=57d436634b7b919e09930062d217efa50452d2fa7814f1eb5988006211bd516fStored in directory: c:\users\hsgpc\appdata\local\pip\cache\wheels\83\8b\7c\09ae60c42c7ba4ed2dddaf2b8b9186cb105255856d6ed3dba5
Successfully built fire python-docx
Installing collected packages: pyclipper, lmdb, termcolor, shapely, rapidfuzz, python-docx, PyMuPDF, opencv-contrib-python, cssutils, cachetools, attrdict, premailer, fire, pdf2docx, imgaug, paddleocr
Successfully installed PyMuPDF-1.20.2 attrdict-2.0.1 cachetools-5.3.1 cssutils-2.7.1 fire-0.5.0 imgaug-0.4.0 lmdb-1.4.1 opencv-contrib-python-4.6.0.66 paddleocr-2.7.0.2 pdf2docx-0.5.6 premailer-3.10.0 pyclipper-1.3.0.post4 python-docx-0.8.11 rapidfuzz-3.2.0 shapely-2.0.1 termcolor-2.3.0(base) D:\ProgramData\Anaconda3>

四、测试安装是否成功
copy word_1.jpg文件到D:\ProgramData\Anaconda3>下面
然后执行检查命令:paddleocr --image_dir ./word_1.jpg --use_angle_cls true

(base) D:\ProgramData\Anaconda3>paddleocr --image_dir ./word_1.jpg --use_angle_cls true

执行结果如下所示:表示安装成功 OK

(base) D:\ProgramData\Anaconda3>paddleocr --image_dir ./word_1.jpg --use_angle_cls true
[2023/08/12 18:10:25] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=True, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir='./word_1.jpg', page_num=0, det_algorithm='DB', det_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\det\\ch\\ch_PP-OCRv4_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\rec\\ch\\ch_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='D:\\ProgramData\\Anaconda3\\lib\\site-packages\\paddleocr\\ppocr\\utils\\ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=True, cls_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\cls\\ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, return_word_box=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')
[2023/08/12 18:10:31] ppocr INFO: **********./word_1.jpg**********
[2023/08/12 18:10:32] ppocr DEBUG: dt_boxes num : 14, elapse : 0.6729228496551514
[2023/08/12 18:10:32] ppocr DEBUG: cls num  : 14, elapse : 0.19803142547607422
[2023/08/12 18:10:32] ppocr DEBUG: rec_res num  : 14, elapse : 0.1495964527130127
[2023/08/12 18:10:32] ppocr INFO: [[[2230.0, 639.0], [3652.0, 575.0], [3665.0, 843.0], [2243.0, 907.0]], ('任重道远 众志成城', 0.9414699077606201)]
[2023/08/12 18:10:32] ppocr INFO: [[[441.0, 690.0], [1633.0, 663.0], [1640.0, 931.0], [447.0, 958.0]], ('有浩然学无止境', 0.9909616112709045)]
[2023/08/12 18:10:32] ppocr INFO: [[[3915.0, 1028.0], [4223.0, 1017.0], [4225.0, 1079.0], [3917.0, 1091.0]], ('四川省长宁县培风中学', 0.9919702410697937)]
[2023/08/12 18:10:32] ppocr INFO: [[[4147.0, 1094.0], [4325.0, 1094.0], [4325.0, 1147.0], [4147.0, 1147.0]], ('班务栏', 0.9993979334831238)]
[2023/08/12 18:10:32] ppocr INFO: [[[1146.0, 1152.0], [1670.0, 1142.0], [1672.0, 1223.0], [1147.0, 1234.0]], ('育才沃土厚德培风', 0.9650142788887024)]
[2023/08/12 18:10:32] ppocr INFO: [[[3595.0, 1327.0], [3808.0, 1302.0], [3818.0, 1388.0], [3605.0, 1412.0]], ('应到56人', 0.9699130058288574)]
[2023/08/12 18:10:32] ppocr INFO: [[[1536.0, 1406.0], [2329.0, 1395.0], [2332.0, 1600.0], [1539.0, 1612.0]], ('领奖典礼', 0.7956822514533997)]
[2023/08/12 18:10:32] ppocr INFO: [[[3587.0, 1404.0], [3802.0, 1373.0], [3816.0, 1464.0], [3601.0, 1495.0]], ('实到5久', 0.8031215667724609)]
[2023/08/12 18:10:32] ppocr INFO: [[[3511.0, 1458.0], [3820.0, 1458.0], [3820.0, 1558.0], [3511.0, 1558.0]], ('请假人罗芯蕊', 0.8602134585380554)]
[2023/08/12 18:10:32] ppocr INFO: [[[139.0, 1569.0], [407.0, 1557.0], [410.0, 1629.0], [142.0, 1640.0]], ('值日生:牟祖浩南', 0.8638275861740112)]
[2023/08/12 18:10:32] ppocr INFO: [[[140.0, 1639.0], [255.0, 1639.0], [255.0, 1697.0], [140.0, 1697.0]], ('英语', 0.9928290843963623)]
[2023/08/12 18:10:32] ppocr INFO: [[[2277.0, 1707.0], [2580.0, 1696.0], [2583.0, 1782.0], [2280.0, 1793.0]], ('年7月30F', 0.8894579410552979)]
[2023/08/12 18:10:32] ppocr INFO: [[[130.0, 1878.0], [217.0, 1878.0], [217.0, 1936.0], [130.0, 1936.0]], ('地理', 0.9972861409187317)]
[2023/08/12 18:10:32] ppocr INFO: [[[3877.0, 2428.0], [4518.0, 2428.0], [4518.0, 2495.0], [3877.0, 2495.0]], ('2023.07.3015:32', 0.9787216186523438)](base) D:\ProgramData\Anaconda3>

五、代码测试安装情况
代码中的图片下载 地址:https://gitee.com/paddlepaddle/PaddleOCR/
https://gitee.com/paddlepaddle/PaddleOCR/tree/release/2.6/doc/imgs
执行结果如下所示:

PS E:\project\python> & D:/ProgramData/Anaconda3/python.exe e:/project/python/OCR/test.py
[2023/08/12 18:33:50] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=True, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\det\\ch\\ch_PP-OCRv4_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\rec\\ch\\ch_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='D:\\ProgramData\\Anaconda3\\lib\\site-packages\\paddleocr\\ppocr\\utils\\ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=True, cls_model_dir='C:\\Users\\hsgpc/.paddleocr/whl\\cls\\ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, return_word_box=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')
[2023/08/12 18:33:57] ppocr DEBUG: dt_boxes num : 16, elapse : 0.6102132797241211
[2023/08/12 18:33:57] ppocr DEBUG: cls num  : 16, elapse : 0.1960291862487793
[2023/08/12 18:33:57] ppocr DEBUG: rec_res num  : 16, elapse : 0.3260536193847656
[[[[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], ('纯臻营养护发素', 0.9978375434875488)], [[[26.0, 83.0], [173.0, 83.0], [173.0, 104.0], [26.0, 104.0]], ('产品信息/参数', 0.9898294806480408)], [[[27.0, 112.0], [331.0, 112.0], [331.0, 135.0], [27.0, 135.0]], ('(45元/每公斤,100公斤起订)', 0.9659178256988525)], [[[25.0, 143.0], [281.0, 143.0], [281.0, 165.0], [25.0, 165.0]], ('每瓶22元,1000瓶起订)', 0.9928629994392395)], [[[26.0, 179.0], [300.0, 179.0], [300.0, 195.0], [26.0, 195.0]], ('【品牌】:代加工方式/OEMODM', 0.9843926429748535)], [[[26.0, 210.0], [234.0, 210.0], [234.0, 227.0], [26.0, 227.0]], ('【品名】:纯臻营养护发素', 0.996315062046051)], [[[25.0, 239.0], [241.0, 239.0], [241.0, 259.0], [25.0, 259.0]], ('【产品编号】:YM-X-3011', 0.9848002791404724)], [[[413.0, 232.0], [430.0, 232.0], [430.0, 306.0], [413.0, 306.0]], ('ODMOEM', 0.9908029437065125)], [[[24.0, 271.0], [180.0, 271.0], [180.0, 290.0], [24.0, 290.0]], ('【净含量】:220ml', 0.9892310500144958)], [[[26.0, 303.0], [251.0, 303.0], [251.0, 319.0], [26.0, 319.0]], ('【适用人群】:适合所有肤质', 0.9909216165542603)], [[[26.0, 335.0], [344.0, 335.0], [344.0, 352.0], [26.0, 352.0]], ('【主要成分】:鲸蜡硬脂醇、燕麦β-葡聚', 0.9828618764877319)], [[[26.0, 364.0], [281.0, 364.0], [281.0, 384.0], [26.0, 384.0]], ('糖、椰油酰胺丙基甜菜碱、泛醌', 0.9505151510238647)], [[[368.0, 368.0], [477.0, 368.0], [477.0, 389.0], [368.0, 389.0]], ('(成品包材)', 0.992070734500885)], [[[26.0, 397.0], [360.0, 397.0], [360.0, 414.0], [26.0, 414.0]], ('【主要功能】:可紧致头发磷层,从而达到', 0.9904309511184692)], [[[28.0, 429.0], [370.0, 429.0], [370.0, 445.0], [28.0, 445.0]], ('即时持久改善头发光泽的效果,给干燥的头', 0.9874164462089539)], [[[27.0, 458.0], [137.0, 458.0], [137.0, 479.0], [27.0, 479.0]], ('发足够的滋养', 0.9987378716468811)]]
PS E:\project\python> 

测试代码test.py内容如下所示:

import os
#os.environ['KMP_DUPLICATE_LIB_OK']='True'   
#如果报错就打开上一行代码,
#报错信息:OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
#表示libiomp5md.dll文件有多个文件在安装目录下D:\ProgramData\Anaconda3
#另一种解办法:搜索libiomp5md.dll多个文件,删除其中一个,这里删除的是\lib\site-packages\paddle\libs\libiomp5md.dll
#注意:删除文件前需要先备份哦from paddleocr import PaddleOCR, draw_ocr#终端需要转到程序所在目录,目录位置要正确,不然找不图片
#如PS E:\project\python>
#图片位置于E:\project\python\OCR\data\11.jpg
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
img_path = './OCR/data/11.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:print(line)# 显示结果
from PIL import Image
#PaddleOCR示例代码需要修改成如下代码才能运行OK 
image = Image.open(img_path).convert('RGB')
boxes = [detection[0] for line in result for detection in line]
txts = [detection[1][0] for line in result for detection in line]
scores = [detection[1][1] for line in result for detection in line]
im_show = draw_ocr(image, boxes, txts, scores)
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

—the—end—

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/70041.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FastAPI入门

目录 FastAPI FastAPI 是什么 为什么要用 FastAPI FastAPI 入门 安装 用 FastAPI 写个接口 调试接口 创建快捷请求 保存为快捷请求 发送请求 总结 FastAPI FastAPI 是什么 什么是 FastAPI 呢&#xff1f; FastAPI 是 Python 的一个框架&#xff0c;如果要类比的话…

ReactNative进阶(三十四):ipa Archive 阶段报错error: Multiple commands produce问题修复及思考

文章目录 一、前言二、问题描述三、问题解决四、拓展阅读五、拓展阅读 一、前言 在应用RN开发跨平台APP阶段&#xff0c;从git中拉取项目&#xff0c;应用Jenkins进行组包时&#xff0c;发现最终生成的ipa安装包版本号始终与项目中设置的版本号不一致。 二、问题描述 经过仔…

C++11并发与多线程笔记(3)线程传参详解,detach()大坑,成员函数做线程函数

C11并发与多线程笔记&#xff08;3&#xff09;线程传参详解&#xff0c;detach 大坑&#xff0c;成员函数做线程函数 1、传递临时对象作为线程参数1.1 要避免的陷阱11.2 要避免的陷阱21.3 总结 2、临时对象作为线程参数2.1 线程id概念2.2 临时对象构造时机抓捕 3、传递类对象…

Mac OS minicom 无法设置921600问题

MacOS minicom 无法设置921600问题 介绍过程解决方案参考资料 介绍 minicom是Mac上一款非常好用的串口工具。本文假设你已经安装minicom&#xff0c;并且知道minicom的一般配置和使用方法。这是“MacOS minicom 无法设置921600”的解决问题记录。它在以下环境中设置成功&#…

flutter:webview_flutter的简单使用

前言 最近在研究如何在应用程序中嵌入Web视图&#xff0c;发现有两个库不错。 一个是官方维护、一个是第三方维护。因为没说特别的需求&#xff0c;就使用了官方库&#xff0c;实现一些简单功能是完全ok的 基本使用 官方文档 https://pub-web.flutter-io.cn/packages/webv…

ansible 修改远程主机nginx配置文件

安装ansible brew install ansible 或者 pip3 install ansible 添加远程主机 设置秘钥 mac登录远程主机 ssh -p 5700 root192.168.123.211 ssh localhost #设置双机信任 ssh-kyegen -t rsa #设置主机两边的ssh配置文件 vi /etc/ssh/sshd_config/ PermitRootL…

Python Opencv实践 - 图像金字塔

import cv2 as cv import numpy as np import matplotlib.pyplot as pltimg cv.imread("../SampleImages/pomeranian.png", cv.IMREAD_COLOR) print(img.shape)#图像上采样 #cv.pyrUp(src, dstNone, dstsizeNone, borderTypeNone) #参考资料&#xff1a;https://blo…

数据库高性能架构模式

互联网业务兴起之后&#xff0c;海量用户加上海量数据的特点&#xff0c;单个数据库服务器已经难以满足业务需要&#xff0c;必须考虑数据库集群的方式来提升性能。高性能数据库集群的第一种方式是“读写分离”&#xff0c;第二种方式是“数据库分片”。 1、读写分离架构 **读…

信息与通信工程面试准备——信号与系统|10:23

8月16日 23:21 目录 ​编辑 1. 调制的作用 2. 放大器与振荡器的作用和区别 工作原理 输出信号 应用 反馈方式 设计复杂度 装置性质 3. 信号与系统&#xff1a;三大变换之间的关系&#xff1f; 4. 无码间串扰的条件 5. 冲激函数的作用&#xff1f; 研究的意义&…

Python系统学习1-9-类(一)

一、类之初印象 1、类就是空表格&#xff0c;将变量&#xff08;列名&#xff09;和函数&#xff08;行为&#xff09;结合起来 2、创建对象&#xff0c;表达具体行 3、创建类就是创建数据的模板 --操作数据时有提示 --还能再组合数据的行为 --结构更加清晰 4、类的内存分配…

ChatGPT爆火,会给教育带来什么样的影响或者冲击?

近来&#xff0c;人工智能聊天机器人ChatGPT连上热搜&#xff0c;火爆全网。ChatGPT拥有强大的信息整合能力、自然语言处理能力&#xff0c;可谓是“上知天文&#xff0c;下知地理”&#xff0c;而且还能根据要求进行聊天、撰写文章等。 ChatGPT一经推出&#xff0c;便迅速在社…

c#设计模式-结构型模式 之 桥接模式

前言 桥接模式是一种设计模式&#xff0c;它将抽象与实现分离&#xff0c;使它们可以独立变化。这种模式涉及到一个接口作为桥梁&#xff0c;使实体类的功能独立于接口实现类。这两种类型的类可以结构化改变而互不影响。 桥接模式的主要目的是通过将实现和抽象分离&#xff0c;…