Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PPOCRLabel开启时报错,打不开 #10748

Closed
CarlWangMing opened this issue Aug 25, 2023 · 16 comments
Closed

PPOCRLabel开启时报错,打不开 #10748

CarlWangMing opened this issue Aug 25, 2023 · 16 comments
Assignees

Comments

@CarlWangMing
Copy link

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem

  • 系统环境/System Environment:python 3.11.4
  • 版本号/Version:Paddle: PaddleOCR: 问题相关组件/Related components:PPOCRLabel
  • 运行指令/Command Code:python.exe D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py
  • 完整报错/Complete Error Message:
    D:\User\Documents\PaddleOCR\Scripts\python.exe D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py
    [2023/08/26 00:11:49] ppocr WARNING: When args.layout is false, args.ocr is automatically set to false
    Traceback (most recent call last):
    File "D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py", line 2840, in
    sys.exit(main())
    ^^^^^^
    File "D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py", line 2828, in main
    app, _win = get_main_app(sys.argv)
    ^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py", line 2818, in get_main_app
    win = MainWindow(lang=args.lang,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\PPOCRLabel\PPOCRLabel.py", line 112, in init
    result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\paddleocr.py", line 759, in call
    res, _ = super().call(
    ^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\ppstructure\predict_system.py", line 129, in call
    res, table_time_dict = self.table_system(
    ^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\ppstructure\table\predict_table.py", line 86, in call
    structure_res, elapse = self._structure(copy.deepcopy(img))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\ppstructure\table\predict_table.py", line 109, in structure
    structure_res, elapse = self.table_structurer(copy.deepcopy(img))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\ppstructure\table\predict_structure.py", line 120, in call
    data = transform(data, self.preprocess_op)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\Git\PaddleOCR\ppocr\data\imaug_init
    .py", line 56, in transform
    data = op(data)
    ^^^^^^^^
    File "D:\Git\PaddleOCR\ppocr\data\imaug\operators.py", line 94, in call
    img.astype('float32') * self.scale - self.mean) / self.std

ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)
我们提供了AceIssueSolver来帮助你解答问题,你是否想要它来解答(请填写yes/no)?/We provide AceIssueSolver to solve issues, do you want it? (Please write yes/no):

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

@Gmgge
Copy link
Contributor

Gmgge commented Aug 28, 2023

从报错上面看(213,488,4)应该是图像的透明通道也被读取了,请确认是否修改了部分代码?尤其是图像读取的部分,输入的图像矩阵需要是三通道的,目前在最先版本代码中尚不能复现该问题。

@chenhao86
Copy link

我这边也会报这个错。 python版本 3.11, 代码 是2.7 release。

@Gmgge
Copy link
Contributor

Gmgge commented Aug 30, 2023

@chenhao86 @CarlWangMing 抱歉,在python版本 3.11, 代码 是2.7 release,windows环境 已经复现该问题。
快速修复方法为,修改代码./paddleocr.py 中img_decode函数中515行的return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED) 修改为 return cv2.imdecode(np_arr, cv2.IMREAD_COLOR)

原因如下:
如上文所说,是图像通道问题,由于示例图片是四通道图像,而imread参数使用IMREAD_UNCHANGED,导致透明通道被提取从而引发的通道数溢出问题(需要三通道图像,读取透明通道后变为四通道图像)

@chenhao86
Copy link

@Gmgge 专业啊。

@CarlWangMing
Copy link
Author

感谢大佬

@gissing913
Copy link

最新的2.7.0.3 的paddleocr.py 並沒有加入此修正,導致PPOCRLabel 啟動仍會有相同問題

@qihanghou726
Copy link

@chenhao86 @CarlWangMing 抱歉,在python版本 3.11, 代码 是2.7 release,windows环境 已经复现该问题。 快速修复方法为,修改代码./paddleocr.py 中img_decode函数中515行的return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED) 修改为 return cv2.imdecode(np_arr, cv2.IMREAD_COLOR)

原因如下: 如上文所说,是图像通道问题,由于示例图片是四通道图像,而imread参数使用IMREAD_UNCHANGED,导致透明通道被提取从而引发的通道数溢出问题(需要三通道图像,读取透明通道后变为四通道图像)

牛逼

andyjiang1116 pushed a commit that referenced this issue Sep 21, 2023
…透明色的需求,由于在check_img中以及存在对单通道图像转三通道图像的处理,因此将该四通道图像处理成三通道的图像也放入该check_img,并统一三通道图像输出逻辑。 (#10847)

add:由于函数复杂度增高,增加注释。
@gitcnbubble
Copy link

@chenhao86 @CarlWangMing 抱歉,在python版本 3.11, 代码 是2.7 release,windows环境 已经复现该问题。 快速修复方法为,修改代码./paddleocr.py 中img_decode函数中515行的return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED) 修改为 return cv2.imdecode(np_arr, cv2.IMREAD_COLOR)

原因如下: 如上文所说,是图像通道问题,由于示例图片是四通道图像,而imread参数使用IMREAD_UNCHANGED,导致透明通道被提取从而引发的通道数溢出问题(需要三通道图像,读取透明通道后变为四通道图像)

同样问题,正确解决。
注意:要修改的paddleocr.py文件在报错提示路径中找到【我的错误提示文件路径是**anaconda3\envs\orc\lib\site-packages\paddleocr\paddleocr.py】,我第一次修改的是git下来的文件夹中的,搞错了

@tigflanker
Copy link

关于“ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)”的问题
吃井不忘挖水人,在PPOCRLabel.py脚本里的112行,把result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)这一句注释掉就行了,软件可以正常打开使用

@Miracle-0718
Copy link

关于“ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)”的问题 吃井不忘挖水人,在PPOCRLabel.py脚本里的112行,把result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)这一句注释掉就行了,软件可以正常打开使用

通过这个方法解决了,非常感谢

@Anyson521
Copy link

关于“ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)”的问题
吃井不忘挖水人,在PPOCRLabel.py脚本里的112行,把result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)这一句注释掉就行了,软件可以正常打开使用

我也解决了,但是后面自动标注完,点击确认OK,又闪退了,报错日志是:
Trying to construct an instance of an invalid type, type id: 1055783631
Traceback (most recent call last):
File "PPOCRLabel.py", line 1060, in shapeSelectionChanged
shape.selected = True
AttributeError: 'NoneType' object has no attribute 'selected'

@OrdinaryChen
Copy link

关于“ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)”的问题 吃井不忘挖水人,在PPOCRLabel.py脚本里的112行,把result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)这一句注释掉就行了,软件可以正常打开使用

这是正解 另一个没用

@Haeppypuppy
Copy link

Labe

用了這個解決了 前一個做法沒反應!

@Gmgge
Copy link
Contributor

Gmgge commented Feb 28, 2024

2.7.1依然存在该问题吗?取消示例图片可以运行是因为示例图片是个四通道图像,之前的逻辑处理四通道图像会出现bug,如果不从根本原因上面解决,在标注时遇到四通道图像仍然可能会闪退。

@devenliu
Copy link

方法一:

@chenhao86 @CarlWangMing 抱歉,在python版本 3.11, 代码 是2.7 release,windows环境 已经复现该问题。 快速修复方法为,修改代码./paddleocr.py 中img_decode函数中515行的return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED) 修改为 return cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
原因如下: 如上文所说,是图像通道问题,由于示例图片是四通道图像,而imread参数使用IMREAD_UNCHANGED,导致透明通道被提取从而引发的通道数溢出问题(需要三通道图像,读取透明通道后变为四通道图像)

同样问题,正确解决。 注意:要修改的paddleocr.py文件在报错提示路径中找到【我的错误提示文件路径是**anaconda3\envs\orc\lib\site-packages\paddleocr\paddleocr.py】,我第一次修改的是git下来的文件夹中的,搞错了

方法二:

关于“ValueError: operands could not be broadcast together with shapes (213,488,4) (1,1,3)”的问题 吃井不忘挖水人,在PPOCRLabel.py脚本里的112行,把result = self.table_ocr('./data/paddle.png', return_ocr_result_in_table=True)这一句注释掉就行了,软件可以正常打开使用

实测两者均有效

@Akentoro
Copy link

抱歉,在python版本 3.11, 代码 是2.7 release,windows环境 已经复现该问题。 快速修复方法为,修改代码./paddleocr.py 中img_decode函数中515行的return cv2.imdecode(np_arr, cv2.IMREAD_UNCHANGED) 修改为 return cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
原因如下: 如上文所说,是图像通道问题,由于示例图片是四通道图像,而imread参数使用IMREAD_UNCHANGED,导致透明通道被提取从而引发的通道数溢出问题(需要三通道图像,读取透明通道后变为四通道图像) ------ 我使用的是這個方式不過是要修改PYTHON環境裡的PADDLEOCR.PY像我一樣的小白會誤以為是下載下來的OCR資料夾裡的

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests