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.26k stars 7.82k forks source link

Wrong result with predict_rec and recognition inference model #11899

Closed esb-skle closed 6 months ago

esb-skle commented 7 months ago

Windows 10, WSL2, Ubuntu 20.02. Cuda 11.8 and Cudnn 8.6.0. (CUDA Device: NVIDIA GeForce 940 MX with compute capability 5.0) Python 3.8

I Installed PaddlePaddle GPU via: python3 -m pip install paddlepaddle-gpu==2.6.1 -i https://mirror.baidu.com/pypi/simple

Downloaded the recognition inference models (en_PP-OCRv3_rec_infer and ch_PP-OCRv3_rec_infer) from here

Cloned the Github repo and launched: python tools/infer/predict_rec.py --image_dir=./doc/imgs_words_en/word_10.png --rec_model_dir=inference/en_PP-OCRv3_rec_infer --rec_image_shape= 3,48,320

With the following result: ppocr INFO: Predicts of ./doc/imgs_words_en/word_10.png:('盎', 2.8086626529693604)

Shouldn't I get a proper result with the inference model and the sample image?

If I try another model (ch_PP-OCRv3_rec_infer): python tools/infer/predict_rec.py --image_dir=./doc/imgs_words_en/word_10.png --rec_model_dir=inference/ch_PP-OCRv3_rec_infer --rec_image_shape= 3,48,320

The results are: ppocr INFO: Predicts of ./doc/imgs_words_en/word_10.png:('v設柳r 潜涮勺/,藍甫1茵忘勇卅塔報笼擀犹q关仃芯钧闯渠忧匯宿籽班英午睛裹', 1.0)

TingquanGao commented 7 months ago

please try to change the encoding format of ppocr_keys_v1.txt from utf-8 to Ansi.

esb-skle commented 7 months ago

If I pass the English dictionary and the English model:

python tools/infer/predict_rec.py --image_dir=./doc/imgs_words_en/word_10.png --rec_model_dir=inference/en_PP-OCRv3_rec_infer --rec_image_shape= 3,48,320 --rec_char_dict_path=ppocr/utils/en_dict.txt

Results are: ppocr INFO: Predicts of ./doc/imgs_words_en/word_10.png:('z', 2.8086626529693604)

No difference if I change the en_dict.txt file from UTF-8 to ANSI.

That do not match the same command results explained here.

If I convert the ppocr_keys_v1.txt file from UTF-8 to ANSI, no difference apart from characters becoming "?".

But if I install the paddlepaddle package instead of paddlepaddle-gpu the result is OK: ppocr INFO: Predicts of ./doc/imgs_words_en/word_10.png:('PAIN', 0.9886713027954102)

May the GPU version have an incompatibility? (I've added the GPU specs in the original post).

Results from paddle.utils.run_check() for paddlepaddle-gpu are:

Running verify PaddlePaddle program ... 
I0410 14:05:58.601819 20162 program_interpreter.cc:212] New Executor is Running.
W0410 14:05:58.602079 20162 gpu_resources.cc:96] The GPU architecture in your current machine is Maxwell, which is not compatible with Paddle installation with arch: 61 70 75 80 86 , it is recommended to install the corresponding wheel package according to the installation information on the official Paddle website.
W0410 14:05:58.602118 20162 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 5.0, Driver API Version: 12.3, Runtime API Version: 11.8
W0410 14:05:58.630391 20162 gpu_resources.cc:164] device: 0, cuDNN Version: 8.6.
I0410 14:05:58.888769 20162 interpreter_util.cc:624] Standalone Executor is Used.
PaddlePaddle works well on 1 GPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
TingquanGao commented 7 months ago

I noticed that W0410 14:05:58.602079 20162 gpu_resources.cc:96] The GPU architecture in your current machine is Maxwell, which is not compatible with Paddle installation with arch: 61 70 75 80 86 , it is recommended to install the corresponding wheel package according to the installation information on the official Paddle website.. Paddle dont support this GPU yet. So you may need to compile and install by yourself. Please refer to: https://www.paddlepaddle.org.cn/documentation/docs/en/install/compile/fromsource_en.html

TingquanGao commented 6 months ago

The issue has been closed. Reopen or new one if you have any questions.