Skip to content

NRTR Export mismatch dim #15082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
leduy-it opened this issue Apr 28, 2025 · 3 comments
Open
3 tasks done

NRTR Export mismatch dim #15082

leduy-it opened this issue Apr 28, 2025 · 3 comments
Assignees

Comments

@leduy-it
Copy link

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

I'm trying export and using NRTR model follow doc, but i encounter, i'm using paddlepaddle-gpu==2.6.2
Reproduce just download the weight and do the same follow the doc:
https://paddlepaddle.github.io/PaddleOCR/main/en/algorithm/text_recognition/algorithm_rec_nrtr.html#41-python-inference

python3 tools/infer/predict_rec.py --image_dir='./image/12.jpg' --rec_model_dir='./inference/rec_mtb_nrtr/' --rec_algorithm='NRTR' --rec_image_shape='1,32,100' --rec_char_dict_path='./ppocr/utils/EN_symbol_dict.txt'
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
[2025/04/28 11:43:18] ppocr WARNING: The first GPU is used for inference by default, GPU ID: 0
[2025/04/28 11:43:20] ppocr INFO: In PP-OCRv3, rec_image_shape parameter defaults to '3, 48, 320', if you are using recognition model with PP-OCRv2 or an older version, please set --rec_image_shape='3,32,320
norm_img_batch shape before inference: (1, 1, 32, 100)
[2025/04/28 11:43:21] ppocr INFO: Traceback (most recent call last):
File "/workspace/JP_FreeForm/tools/infer/predict_rec.py", line 937, in main
rec_res, _ = text_recognizer(img_list)
File "/workspace/JP_FreeForm/tools/infer/predict_rec.py", line 870, in call
self.predictor.run()
ValueError: (InvalidArgument) The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [1, 2, 1536], X's size = 3072, 'shape' is [1, 1, 3, 8, 64], the capacity of 'shape' is 1536.
[Hint: Expected capacity == in_size, but received capacity:1536 != in_size:3072.] (at /paddle/paddle/phi/infermeta/unary.cc:1955)
[operator < reshape2 > error]

[2025/04/28 11:43:21] ppocr INFO: (InvalidArgument) The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [1, 2, 1536], X's size = 3072, 'shape' is [1, 1, 3, 8, 64], the capacity of 'shape' is 1536.
[Hint: Expected capacity == in_size, but received capacity:1536 != in_size:3072.] (at /paddle/paddle/phi/infermeta/unary.cc:1955)
[operator < reshape2 > error]

Thanks in advanced!

🏃‍♂️ Environment (运行环境)

ubtuntu
paddlepaddle-gpu==2.6.2
latest paddleocr

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

python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words_en/word_10.png' --rec_model_dir='./inference/rec_mtb_nrtr/' --rec_algorithm='NRTR' --rec_image_shape='1,32,100' --rec_char_dict_path='./ppocr/utils/EN_symbol_dict.txt'

@TingquanGao TingquanGao self-assigned this Apr 28, 2025
@cuicheng01
Copy link
Collaborator

Hello, could you please try using paddle version 3.0? If you encounter any detailed error messages, please let us know. Thank you!

@leduy-it
Copy link
Author

@cuicheng01 Thanks for your quickly reply. Yes, i have try version 3.0 and still the same error was raised.
Can you take a look for this algothrim because it's has been released quite a long time and need some new documents.
Hope some good new from u!
Thanks.

@leduy-it
Copy link
Author

@cuicheng01 More information that i can training and evaluation with pdparams smoothly but when i wanna export it to static pdinference, i counter this error.
@Topdu and Topdu i know you are the author of this algorithm, can you give me some help or at least advice, thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants