PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.45k stars 7.84k forks source link

numpy version issue #13991

Open agzeroo opened 1 month ago

agzeroo commented 1 month ago

🔎 Search before asking

🐛 Bug (问题描述)

Hi. I was using numpy version 1.26.3 and there was no problem. But when numpy version becomes 2.0 or higher, the problem occurs. Is there any way to solve this problem as quickly as possible? https://github.com/PaddlePaddle/PaddleOCR/pull/13937#issue-2560596355

🏃‍♂️ Environment (运行环境)

paddlepaddle-gpu 2.5.2

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

OmarFaig commented 1 month ago

Downgrade NumPy: Since you mentioned that the problem does not occur with NumPy version 1.26.3, a temporary workaround would be to downgrade to that version: pip install numpy==1.26.3

agzeroo commented 1 month ago

@OmarFaig Thanks for the reply.

But I need to make paddleocr work in an environment where numpy 2.0 or higher is installed....

GreatV commented 1 month ago

cannot work for numpy geater than 2.0, for quick apply new numpy version, try this https://github.com/PaddlePaddle/PaddleOCR/pull/13467

agzeroo commented 1 month ago

@GreatV

13937 [WIP] Is there a difference between upgrade to numpy 2.0 and remove imgaug and #13467? I'm trying it, but I still don't get the result in numpy 2.0 or higher.

image

Package Version albucore 0.0.17 albumentations 1.4.18 annotated-types 0.7.0 anyio 4.6.2 astor 0.8.1 beautifulsoup4 4.12.3 certifi 2024.8.30 charset-normalizer 3.4.0 click 8.1.7 colorama 0.4.6 contourpy 1.3.0 cycler 0.12.1 Cython 3.0.11 decorator 5.1.1 eval_type_backport 0.2.0 fastapi 0.115.2 fire 0.7.0 fonttools 4.54.1 h11 0.14.0 httpcore 1.0.6 httpx 0.27.2 idna 3.10 imageio 2.36.0 joblib 1.4.2 kiwisolver 1.4.7 lazy_loader 0.4 lmdb 1.5.1 lxml 5.3.0 matplotlib 3.9.2 networkx 3.4.1 numpy 2.1.2 opencv-contrib-python 4.10.0.84 opencv-python 4.10.0.84 opencv-python-headless 4.10.0.84 opt-einsum 3.3.0 packaging 24.1 paddleocr 2.8.1 paddlepaddle-gpu 2.5.2 pillow 10.4.0 pip 24.2 protobuf 3.20.2 pyclipper 1.3.0.post5 pydantic 2.9.2 pydantic_core 2.23.4 PyMuPDF 1.21.1 pyparsing 3.2.0 python-dateutil 2.9.0.post0 python-docx 1.1.2 python-multipart 0.0.12 PyYAML 6.0.2 RapidFuzz 3.10.0 requests 2.32.3 scikit-image 0.24.0 scikit-learn 1.5.2 scipy 1.14.1 setuptools 75.1.0 shapely 2.0.6 six 1.16.0 sniffio 1.3.1 soupsieve 2.6 starlette 0.39.2 termcolor 2.5.0 threadpoolctl 3.5.0 tifffile 2024.9.20 tomli 2.0.2 tqdm 4.66.5 typing_extensions 4.12.2 urllib3 2.2.3 uvicorn 0.31.1 wheel 0.44.0

GreatV commented 1 month ago

What's the specific numpy version issue you're facing?

agzeroo commented 1 month ago

@GreatV

With numpy 2.1.2, training does not occur at all (loss does not decrease) and inference with a pretrained model does not produce any results. (Running the same data with numpy 1.26.3 produces normal results.)

Trying #13467 also produced the following error, training did not occur, and inference still did not produce any results. error1. Error : (InvalidArgument) Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [2, 256, 7, 7] and the shape of Y = [2, 256, 8, 8]. Received [7] in X is not equal to [8] in Y at i:2 [Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at .. \paddle/phi/kernels/funcs/common_shape.h:86)

GreatV commented 1 month ago

That looks really weird, we'll investigate further.

GreatV commented 5 days ago

@agzeroo Please try our latest main branch to check if the issue is resolved.