飞桨大模型PaddleOCR
一、新建项目PaddleOCRProject
二、查看开源
pip install paddlepaddle
pip install paddleocr
指定镜像源下载才快:
pip install paddlepaddle -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install paddleocr -i https://pypi.tuna.tsinghua.edu.cn/simple
三、编写代码main.py
https://paddlepaddle.github.io/PaddleOCR/latest/quick_start.html#1-paddlepaddle
文本检测+方向分类+文本识别
from paddleocr import PaddleOCR, draw_ocr
# Paddleocr supports Chinese, English, French, German, Korean and Japanese
# You can set the parameter `lang` as `ch`, `en`, `french`, `german`, `korean`, `japan`
# to switch the language model in order
ocr = PaddleOCR(use_angle_cls=True, lang='ch') # need to run only once to download and load model into memory
img_path = 'Snipaste_2024-11-22_23-02-56.png'
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
准备要识别的图片:Snipaste_2024-11-22_23-02-56.png
输出结果:
识别还是非常准的!