PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

Code doesn't work with numpy>=1.24

Open VinhLoiIT opened this issue 2 years ago • 7 comments

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

The code will not work with numpy>=1.24

Reference for the deprecation: https://numpy.org/devdocs/release/1.20.0-notes.html#using-the-aliases-of-builtin-types-like-np-int-is-deprecated

When using paddleocr with the previous numpy versions (<1.24), it just raises some DeprecationWarning. However, numpy has officially removed them in the version 1.24 and onward (>=1.24).

Aside from np.int, np.bool8 would be considered as well

  • 系统环境/System Environment: Ubuntu 22.04
  • 版本号/Version:Paddle 2.6.1: PaddleOCR: 问题相关组件/Related components:
  • 运行指令/Command Code:
  • 完整报错/Complete Error Message:
  ... <hide due to some confidential information>
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/paddleocr.py", line 534, in ocr                                                                                    
    """                                                                                                                                                                    
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/tools/infer/predict_system.py", line 71, in __call__                                                               
    dt_boxes, elapse = self.text_detector(img)                                                                                                                             
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/tools/infer/predict_det.py", line 271, in __call__                                                                 
    post_result = self.postprocess_op(preds, shape_list)                                                                                                                   
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/ppocr/postprocess/db_postprocess.py", line 240, in __call__                                                        
    boxes, scores = self.boxes_from_bitmap(pred[batch_index], mask,                                                                                                        
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/ppocr/postprocess/db_postprocess.py", line 131, in boxes_from_bitmap                                               
    score = self.box_score_fast(pred, points.reshape(-1, 2))                                                                                                               
  File "/opt/venv/lib/python3.9/site-packages/paddleocr/ppocr/postprocess/db_postprocess.py", line 188, in box_score_fast                                                 
    xmin = np.clip(np.floor(box[:, 0].min()).astype(np.int), 0, w - 1)                                                                                                     
  File "/opt/venv/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__                                                                                
    raise AttributeError("module {!r} has no attribute "                                                                                                                   
AttributeError: module 'numpy' has no attribute 'int'  

VinhLoiIT avatar Dec 30 '22 04:12 VinhLoiIT

Thanks for your suggestion, we'll discuss it further.

an1018 avatar Jan 03 '23 02:01 an1018

We'vd solved this problem, you can try again

an1018 avatar Jan 06 '23 09:01 an1018

Still doesn't work; installed paddleocr with pip and got the same error - in db_postprocess.py on line 188-191, there are some np.int.

csiki avatar Feb 07 '23 17:02 csiki

use numpy 1.23.5, it's work

bondzhan avatar Jun 14 '23 09:06 bondzhan

同样问题 pip3 install paddleocr paddlepaddle --upgrade PyMuPDF==1.21.1

OS:              macOS 13.5
paddleocr             2.6.0.1
paddlepaddle          2.5.1
numpy 版本 是否工作
1.25.2 N
1.24.4 N
1.24.0 N
1.23.5 Y

目前可用一行命令 pip3 install paddleocr paddlepaddle --upgrade PyMuPDF==1.21.1 'numpy<1.24'

4ft35t avatar Aug 07 '23 02:08 4ft35t

same problem,I'm using pip3 install paddleocr paddlepaddle --upgrade PyMuPDF==1.21.1

tjc0726 avatar Aug 08 '23 11:08 tjc0726

这个问题解决了吗?我这边还是不行,

这样根据网上的建议,安装的 paddleocr

pip.exe install "paddleocr>=2.0.1" --upgrade PyMuPDF==1.21.1

因为不加 --upgrade PyMuPDF==1.21.1 就会有 ERROR: Failed building wheel for PyMuPDF

哎,感觉步步是坑,这个库有百度有人认真的维护吗?

jcyrss avatar Dec 06 '23 03:12 jcyrss

问题在PR #12249 中已经修复了,issue先行关闭了,有问题再开

SWHL avatar Jun 05 '24 06:06 SWHL