Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Bug] 处理 img.ndim=2 的图像时,发生错误 #116

Closed
imClumsyPanda opened this issue Sep 5, 2023 · 3 comments
Closed

[Bug] 处理 img.ndim=2 的图像时,发生错误 #116

imClumsyPanda opened this issue Sep 5, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@imClumsyPanda
Copy link

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

  • 系统环境/System Environment:macOS
  • 使用的是哪门语言的程序/Which programing language:Python
  • 所使用语言相关版本信息/Version:3.8
  • OnnxRuntime版本/OnnxRuntime Version:1.15.1
  • 可复现问题的demo/Demo of reproducible problems

在读取 img.ndim = 2 的图像时,发生如下报错信息:

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/liuqian/Downloads/Langchain-Chatchat/pdf.py", line 6, in <module>
    docs = loader.load()
  File "/opt/homebrew/Caskroom/miniforge/base/envs/chatchat/lib/python3.8/site-packages/langchain/document_loaders/unstructured.py", line 86, in load
    elements = self._get_elements()
  File "/Users/liuqian/Downloads/Langchain-Chatchat/document_loaders/mypdfloader.py", line 29, in _get_elements
    text = pdf2text(self.file_path)
  File "/Users/liuqian/Downloads/Langchain-Chatchat/document_loaders/mypdfloader.py", line 23, in pdf2text
    result, _ = ocr(img_array)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/chatchat/lib/python3.8/site-packages/rapidocr_onnxruntime/rapid_ocr_api.py", line 74, in __call__
    dt_boxes, det_elapse = self.text_detector(img)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/chatchat/lib/python3.8/site-packages/rapidocr_onnxruntime/ch_ppocr_v3_det/text_detect.py", line 65, in __call__
    data = transform(data, self.preprocess_op)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/chatchat/lib/python3.8/site-packages/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py", line 225, in transform
    data = op(data)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/chatchat/lib/python3.8/site-packages/rapidocr_onnxruntime/ch_ppocr_v3_det/utils.py", line 79, in __call__
    data["image"] = (img * self.scale - self.mean) / self.std
ValueError: operands could not be broadcast together with shapes (1568,1120) (1,1,3) 

经与 img.ndim=3 的图像处理时的对比发现,发生此报错的原因是 img * self.scale 为 15681120 维矩阵,self.mean 为 11*3 维矩阵无法执行计算导致。

@SWHL SWHL added the bug Something isn't working label Sep 5, 2023
@SWHL
Copy link
Collaborator

SWHL commented Sep 5, 2023

有可以复现问题的最小代码和文件吗?我这里咋复现不出来呢?

SWHL added a commit that referenced this issue Sep 6, 2023
@SWHL
Copy link
Collaborator

SWHL commented Sep 6, 2023

已经在rapidocr_onnxruntime==1.3.1中修复,请再次尝试

@imClumsyPanda
Copy link
Author

@SWHL 非常感谢!升级1.3.2版本后已解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Archived in project
Development

No branches or pull requests

2 participants