PaddleOCR
PaddleOCR copied to clipboard
OCR识别完成后,生成结果图片时draw_ocr出错
请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem
- 系统环境/System Environment:Win10
- 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:PyCharm python3.6 PaddleOCR 2.6.0.2 paddlepaddle 2.3.2
- 运行指令/Command Code:im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/ArialMT.ttf')
- 完整报错/Complete Error Message:
Traceback (most recent call last):
File "I:/pythonserver/paddleocr/ocr.py", line 20, in
im_show = draw_ocr(image, boxes, txts, scores, font_path='./fonts/ArialMT.ttf') File "I:\pythonserver\paddleocr\venv\lib\site-packages\paddleocr\tools\infer\utility.py", line 382, in draw_ocr if scores is not None and (scores[i] < drop_score or TypeError: '<' not supported between instances of 'tuple' and 'float'
I encountered the same issue one hour ago. The problem is indeed in the example but not the draw_ocr
function itself.
Modified the "draw the result" part as follows and it worked:
# draw result
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [detection[0] for line in result for detection in line] # Nested loop added
txts = [detection[1][0] for line in result for detection in line] # Nested loop added
scores = [detection[1][1] for line in result for detection in line] # Nested loop added
im_show = draw_ocr(image, boxes, txts, scores, , font_path='./fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('test.jpg')
你好,麻烦用最新的代码编译whl包安装试下
I encountered the same issue one hour ago. The problem is indeed in the example but not the
draw_ocr
function itself.Modified the "draw the result" part as follows and it worked:
# draw result from PIL import Image image = Image.open(img_path).convert('RGB') boxes = [detection[0] for line in result for detection in line] # Nested loop added txts = [detection[1][0] for line in result for detection in line] # Nested loop added scores = [detection[1][1] for line in result for detection in line] # Nested loop added im_show = draw_ocr(image, boxes, txts, scores, , font_path='./fonts/simfang.ttf') im_show = Image.fromarray(im_show) im_show.save('test.jpg')
Thanks,it worked
参考最新文档哈 https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/quickstart.md#22-python%E8%84%9A%E6%9C%AC%E4%BD%BF%E7%94%A8
参考最新文档哈 https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/quickstart.md#22-python%E8%84%9A%E6%9C%AC%E4%BD%BF%E7%94%A8 这个也可以了