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