PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

OCR识别完成后,生成结果图片时draw_ocr出错

Open bxjxxyy opened this issue 2 years ago • 5 comments

请提供下述完整信息以便快速定位问题/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'

bxjxxyy avatar Oct 13 '22 07:10 bxjxxyy

I encountered the same issue one hour ago. The problem is indeed in the example but not the draw_ocr function itself.

This example

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')

aaronsl-hku avatar Oct 14 '22 03:10 aaronsl-hku

你好,麻烦用最新的代码编译whl包安装试下

littletomatodonkey avatar Oct 14 '22 13:10 littletomatodonkey

I encountered the same issue one hour ago. The problem is indeed in the example but not the draw_ocr function itself.

This example

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

bxjxxyy avatar Oct 14 '22 14:10 bxjxxyy

你好,麻烦用最新的代码编译whl包安装试下

昨天就是根据文档里面操作的,使用的最新的代码。上面aaronsl-hku给出的办法起作用了

bxjxxyy avatar Oct 14 '22 14:10 bxjxxyy

参考最新文档哈 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

andyjiang1116 avatar Oct 17 '22 09:10 andyjiang1116

参考最新文档哈 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 这个也可以了

bxjxxyy avatar Oct 25 '22 01:10 bxjxxyy