已解决TypeError: __init__() got an unexpected keyword argument ‘threshold‘

已解决(paddleocr模块PPStructure(show_log=True)报错)TypeError: init() got an unexpected keyword argument ‘threshold‘









报错代码



粉丝群里面的一个小伙伴想用python cv2模块和paddleocr 模块做图像识别复制别人的代码报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下:

import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res



table_engine = PPStructure(show_log=True)

img_path = './.png'
img = cv2.imread(img_path)
result = table_engine(img)
print(result)
# save_structure_res(result, 'where', 'ex01')#存放位置


报错信息截图


在这里插入图片描述

Traceback (most recent call last):
  File "E:/Python/test1.py", line 6, in <module>
    table_engine = PPStructure(show_log=True)
  File "D:\Python3.8\lib\site-packages\paddleocr\paddleocr.py", line 534, in __init__
    super().__init__(params)
  File "D:\Python3.8\lib\site-packages\paddleocr\ppstructure\predict_system.py", line 62, in __init__
    self.table_layout = lp.PaddleDetectionLayoutModel(
TypeError: __init__() got an unexpected keyword argument 'threshold'



报错翻译



报错信息翻译

类型错误:__init__()获取了意外的关键字参数“阈值”




报错原因



报错原因:猜测可能是由于paddleocr版本太低了导致报错




解决方法



用pip命令升级paddleocr模块的版本:

pip install --upgrade paddlepaddle

出现版本表明安装成功了:

在这里插入图片描述


帮忙解决

本文已收录于:《告别Bug》专栏

本专栏用于记录学习和工作中遇到的各种疑难Bug问题,以及粉丝群里小伙伴提出的各种问题,文章形式:报错代码 + 报错翻译 + 报错原因 + 解决方法,包括程序安装、运行程序过程中等等问题,订阅专栏+关注博主后如遇到其他问题可私聊帮忙解决!!!

猜你喜欢

转载自blog.csdn.net/yuan2019035055/article/details/126345376