安装PaddleOCR-2.7.0版本-笔记

news2024/12/24 8:09:13

安装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.58
  Downloading 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-python
  Attempting uninstall: opencv-python
    Found existing installation: opencv-python 4.5.4.60
    Uninstalling 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 paddleocr
  Downloading 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.0
  Downloading fire-0.5.0.tar.gz (88 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.3/88.3 kB 277.7 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting PyMuPDF<1.21.0
  Downloading 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 pdf2docx
  Downloading pdf2docx-0.5.6-py3-none-any.whl (148 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.4/148.4 kB 53.9 kB/s eta 0:00:00
Collecting pyclipper
  Downloading 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 imgaug
  Downloading 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 premailer
  Downloading 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-docx
  Downloading python-docx-0.8.11.tar.gz (5.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/5.6 MB 99.6 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: visualdl in d:\programdata\anaconda3\lib\site-packages (from paddleocr) (2.5.3)
Collecting lmdb
  Downloading 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 attrdict
  Downloading 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 rapidfuzz
  Downloading 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.66
  Downloading 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 shapely
  Downloading 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 termcolor
  Downloading 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 cssutils
  Downloading cssutils-2.7.1-py3-none-any.whl (399 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 399.7/399.7 kB 154.8 kB/s eta 0:00:00
Collecting cachetools
  Downloading 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-docx
  Building wheel for fire (setup.py) ... done
  Created wheel for fire: filename=fire-0.5.0-py2.py3-none-any.whl size=116933 sha256=990b480b38515263ad3ecb8ff990b5de7a6878ec67a34c25a531b5352db1c6fa
  Stored in directory: c:\users\hsgpc\appdata\local\pip\cache\wheels\f7\f1\89\b9ea2bf8f80ec027a88fef1d354b3816b4d3d29530988972f6
  Building wheel for python-docx (setup.py) ... done
  Created wheel for python-docx: filename=python_docx-0.8.11-py3-none-any.whl size=184489 sha256=57d436634b7b919e09930062d217efa50452d2fa7814f1eb5988006211bd516f
  Stored 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.coloradmin.cn/o/868688.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

线程介绍,线程与进程区别,如何使用多线程,Thread类,Runnable接口,补充知识(方法重载,方法重写)

引言&#xff1a;搞进程是为了什么呢&#xff1f; 满足并发编程&#xff0c;这样的需求&#xff0c;cpu多个核心&#xff0c;应用程序做出对应调整&#xff0c;让代码可以把多个核心充分利用起来&#xff5e;&#xff0c;当需要支持多个任务的时候——进程就十分关键了&#x…

8月9日上课内容 nginx反向代理与负载均衡

负载均衡工作当中用的很多的&#xff0c;也是面试会问的很重要的一个点 负载均衡&#xff1a;通过反向代理来实现&#xff08;nginx只有反向代理才能做负载均衡&#xff09; 正向代理的配置方法&#xff08;用的较少&#xff09; 反向代理的方式&#xff1a;四层代理与七层代…

Golang 函数定义及使用

文章目录 一、函数定义格式二、函数定义及使用 一、函数定义格式 //func: 函数定义关键字 //function_name&#xff1a;函数名称 //parameter_List: 函数参数列表&#xff0c;多个时使用逗号拆分 //return_types&#xff1a;函数返回类型&#xff0c;返回多个值时使用逗号拆分…

2023河南萌新联赛第(五)场:郑州轻工业大学-F 布鲁特佛斯

2023河南萌新联赛第&#xff08;五&#xff09;场&#xff1a;郑州轻工业大学-F 布鲁特佛斯 https://ac.nowcoder.com/acm/contest/62977/F 文章目录 2023河南萌新联赛第&#xff08;五&#xff09;场&#xff1a;郑州轻工业大学-F 布鲁特佛斯题意解题思路代码 题意 给定一个…

前后端分离------后端创建笔记(02)

本文章转载于【SpringBootVue】全网最简单但实用的前后端分离项目实战笔记 - 前端_大菜007的博客-CSDN博客 仅用于学习和讨论&#xff0c;如有侵权请联系 源码&#xff1a;https://gitee.com/green_vegetables/x-admin-project.git 素材&#xff1a;https://pan.baidu.com/s/…

《甲午》观后感——GPT-3.5所写

《甲午》是一部令人深思的纪录片&#xff0c;通过生动的画面和真实的故事&#xff0c;向观众展示了中国历史上的一段重要时期。观看这部纪录片&#xff0c;我深受触动&#xff0c;对历史的认识也得到了深化。 首先&#xff0c;这部纪录片通过精心搜集的历史资料和珍贵的影像资料…

SLF4J日志绑定原理分析

前言 最近做项目&#xff0c;实际上也知道日志冲突的事&#xff0c;不过涉及MDC NDC数据传递&#xff0c;当日志框架冲突后&#xff0c;MDC和NDC就失效了&#xff0c;这里就涉及slf4j-api的MDC的绑定的过程&#xff0c;顺便分析了日志冲突实际生效的原因&#xff0c;理解SLF4J…

JavaScript类

JavaScript 类(class) 类是用于创建对象的模板。 我们使用 class 关键字来创建一个类&#xff0c;类体在一对大括号 {} 中&#xff0c;我们可以在大括号 {} 中定义类成员的位置&#xff0c;如方法或构造函数。 每个类中包含了一个特殊的方法 constructor()&#xff0c;它是类…

395. 至少有 K 个重复字符的最长子串

395. 至少有 K 个重复字符的最长子串 C代码&#xff1a;滑动窗口 ---- 不是吧&#xff0c;阿sir&#xff0c;这也能滑&#xff1f; // 返回滑动窗口的长度 // 满足条件的种类数量的可能为 [1, 26], 所以需要遍历26中情况的窗口长度 // 当 区间内所有种类数量 满足要求的种类数…

【Anaconda】安装及使用

知识目录 前言一、 Anaconda是什么二、为什么使用Anaconda三、安装步骤3.1 下载安装3.2 配置conda源 结语 前言 大家好&#xff01;我是向阳花花花花&#xff0c;本期给大家带来的是 Anaconda 安装及使用。 每日金句分享&#xff1a;故事不长&#xff0c;也不难讲。』—— 「…

深度学习(37)—— 图神经网络GNN(2)

深度学习&#xff08;37&#xff09;—— 图神经网络GNN&#xff08;2&#xff09; 这一期主要是一些简单示例&#xff0c;针对不同的情况&#xff0c;使用的数据都是torch_geometric的内置数据集 文章目录 深度学习&#xff08;37&#xff09;—— 图神经网络GNN&#xff08…

SpringCloudGateway配置跨域设置以及如何本地测试跨域

问题背景 有个服务A &#xff0c;自身对外提供服务&#xff0c;几个系统的前端页面也在调用&#xff0c;使用springboot 2.6.8开发的&#xff0c;自身因为有前端直接调用已经配置了跨域。 现在有网关服务&#xff0c;一部分前端通过网关访问服务A&#xff08;因为之前没有网关…

Android系统-ServiceManager2

目录 引言&#xff1a; 获取ServiceManager 流程图 注册系统服务 获取系统服务 引言&#xff1a; 注册或使用服务之前&#xff0c;需要通过ServiceManager这个DNS来找到对应的服务。那怎么找到ServiceManager呢&#xff1f; 怎么注册系统服务&#xff1f; 怎么获取系统…

分享一组天气组件

先看效果&#xff1a; CSS部分代码&#xff08;查看更多&#xff09;&#xff1a; <style>:root {--bg-color: #E9F5FA;--day-text-color: #4DB0D3;/* 多云 */--cloudy-background: #4DB0D3;--cloudy-temperature: #E6DF95;--cloudy-content: #D3EBF4;/* 晴 */--sunny-b…

Docker高级篇_DockerFile

目录 DockerFile简介构建DockerFile构建过程解析Docker执行Dockerfile的大致流程 DockerFile常用保留字指令FROMMAINTAINERRUNEXPOSEWORKDIRUSERENVVOLUMEADDCOPYCMDENTRYPOINT案例使用虚悬镜像 Docker微服务 DockerFile简介 Dockerfile是用来构建Docker镜像的文本文件&#x…

七、解析应用程序——枚举内容与功能

文章目录 1、web抓取2、发现隐藏内容2.1 蛮力技巧2.2 通过公布的内容进行推测2.3 利用公共信息 3、应用程序页面和功能路径4、发现隐藏参数 攻击应用程序的第一步是收集和分析与其有关的一些关键信息&#xff0c;以清楚了解攻击目标。解析过程首先是枚举应用程序的内容与功能&a…

HTML详解连载(2)

HTML详解连载&#xff08;2&#xff09; 专栏链接 [link](http://t.csdn.cn/xF0H3)下面进行专栏介绍 开始喽超链接作用代码示例解释经验分享 音频标签代码示例注意强调 视频标签代码示例注意强调 列表作用&#xff1a;布局内容排列整齐的区域。分类&#xff1a;无序列表&#x…

基于Googlenet深度学习网络的人员行为动作识别matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 1. 原理 1.1 深度学习与卷积神经网络&#xff08;CNN&#xff09; 1.2 GoogLeNet 2. 实现过程 2.1 数据预处理 2.2 构建网络模型 2.3 数据输入与训练 2.4 模型评估与调优 3. 应用领域…

Eclipse(STS)Enum 格式化配置

需求 枚举类 的字段&#xff0c;一般长度较小&#xff0c;格式化后&#xff0c;多个字段会变为一行。 需求&#xff1a;希望每个字段独立一行。 格式化后的样式&#xff0c;如下图所示&#xff1a; 配置 1. Windows - Preferences 2. Java-Formatter 如果没有自定义的格…

C++ 循环

有的时候&#xff0c;可能需要多次执行同一块代码。一般情况下&#xff0c;语句是顺序执行的&#xff1a;函数中的第一个语句先执行&#xff0c;接着是第二个语句&#xff0c;依此类推。 编程语言提供了允许更为复杂的执行路径的多种控制结构。 循环语句允许我们多次执行一个…