Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
from paddleocr import PaddleOCR,draw_ocr
ocr = PaddleOCR(det_max_side_len=5000,ocr_version="PP-OCRv4",use_angle_cls=False,det_db_score_mode="slow")
img_path = './img_0.jpg'
result = ocr.ocr(img_path, cls=False,rec=False)
for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
draw result
from PIL import Image
result = result[0]
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, result, txts=None, scores=None, font_path='./simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result-det2.jpg')
测试图片:
测试结果:
🔎 Search before asking
🐛 Bug (问题描述)
我使用只有文本检测的代码(https://paddlepaddle.github.io/PaddleOCR/latest/quick_start.html#__tabbed_2_4) 测试,与在线demo(https://aistudio.baidu.com/community/app/91660/webUI) 的结果相差很多。
🏃♂️ Environment (运行环境)
ubuntu 22.04 python 3.12 paddlepaddle = "3.0.0b1" paddleocr = "^2.9.1" 使用cpu版本的模型
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
from paddleocr import PaddleOCR,draw_ocr ocr = PaddleOCR(det_max_side_len=5000,ocr_version="PP-OCRv4",use_angle_cls=False,det_db_score_mode="slow") img_path = './img_0.jpg' result = ocr.ocr(img_path, cls=False,rec=False) for idx in range(len(result)): res = result[idx] for line in res: print(line)
draw result
from PIL import Image result = result[0] image = Image.open(img_path).convert('RGB') boxes = [line[0] for line in result] txts = [line[1][0] for line in result] scores = [line[1][1] for line in result] im_show = draw_ocr(image, result, txts=None, scores=None, font_path='./simfang.ttf') im_show = Image.fromarray(im_show) im_show.save('result-det2.jpg') 测试图片: 测试结果:
在线demo测试时,长边最大值设置为4000,结果: