代码拉取完成,页面将自动刷新
from PIL import Image
from paddleocr import PaddleOCR, draw_ocr
import numpy as np
ocr = PaddleOCR(use_angle_cls=True, lang="ch")
img_path = '33.jpg'
result = ocr.ocr(img_path, cls=True)
image = Image.open(img_path).convert('RGB')
boxes = [elements[0] for line in result for elements in line]
txts = [elements[1][0] for line in result for elements in line]
scores = [elements[1][1] for line in result for elements in line]
# Check the structure of boxes
for i in range(len(boxes)):
print(f"Box {i}: {boxes[i]}")
# Draw OCR result
im_show = draw_ocr(image, boxes, txts, scores, font_path='D:\\xcl\\github\\PaddleOCR\\doc\\fonts\\simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result1.jpg')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。