Alphabet for English rec model is not matching OCR on image
christegho opened this issue · 1 comments
Thank you so much for providing code to convert paddle models to onnx format and be able to use these converted models with rapid OCR.
I used paddleocr_convert to convert the latest english models as follow:
paddleocr_convert -p https://paddleocr.bj.bcebos.com/PP-OCRv4/english/en_PP-OCRv4_rec_infer.tar -o paddle_models -txt_path https://raw.githubusercontent.com/PaddlePaddle/PaddleOCR/release/2.7/ppocr/utils/en_dict.txt
paddleocr_convert -p https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar -o paddle_models
For testing these models, I use the following image
I use rapid ocr to get OCR:
from rapidocr_onnxruntime import RapidOCR
engine = RapidOCR(rec_model_path="paddle_models/en_PP-OCRv4_rec_infer/en_PP-OCRv4_rec_infer.onnx",
det_model_path="paddle_models/en_PP-OCRv3_det_infer/en_PP-OCRv3_det_infer.onnx")
img = "c8fa66439d63041e.jpg"
result, elapse = engine(img)
and I get the following result (I only included the first few predictions):
[[[[551.0, 72.0], [952.0, 83.0], [949.0, 177.0], [548.0, 166.0]],
'DlizAly',
0.8711231350898743],
[[[540.0, 211.0], [978.0, 221.0], [978.0, 250.0], [540.0, 241.0]],
'ulD ADluAplAo jluABy',
0.9064718882242838],
[[[65.0, 280.0], [207.0, 277.0], [207.0, 293.0], [65.0, 297.0]],
"B!QR%%'R}N} T",
0.6442324388772249],
[[[220.0, 286.0], [270.0, 283.0], [270.0, 297.0], [220.0, 300.0]],
'B!QV&P"%R',
0.7667727172374725],
...
Whereas the default models produce more matching results
from rapidocr_onnxruntime import RapidOCR
engine = RapidOCR()
img = "c8fa66439d63041e.jpg"
result, elapse = engine(img)
result -->
[[[[545.0, 72.0], [954.0, 84.0], [951.0, 179.0], [542.0, 167.0]],
'WEBSTER',
0.8526573106646538],
[[[539.0, 210.0], [975.0, 218.0], [975.0, 250.0], [539.0, 243.0]],
'NEW TWENTIETH CENTUR',
0.9136510831969125],
[[[63.0, 280.0], [209.0, 277.0], [209.0, 295.0], [63.0, 299.0]],
'Underrte, r.aa ferg',
0.6786298751831055],
[[[220.0, 285.0], [271.0, 282.0], [271.0, 298.0], [220.0, 301.0]],
'Undlacove',
0.7574679881334305],
This suggests I am perhaps using the wrong dictionary. However, the only dict I could find in the paddle git repo is https://raw.githubusercontent.com/PaddlePaddle/PaddleOCR/release/2.7/ppocr/utils/EN_symbol_dict.txt.
Do you happen to know if there is some step I am doing wrong here?
thank you so much,
Chris
I am closing this issue. After posting the issue, I have noticed that I was using a local dict that was slightly different from the one available with paddle ocr