Skip to content
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

英文模型运行后 抛出java.lang.IndexOutOfBoundsException: Index 96 out of bounds for length 96 #33

Open
biotech7 opened this issue Jun 18, 2023 · 1 comment

Comments

@biotech7
Copy link

biotech7 commented Jun 18, 2023

系统环境: win11/jdk17/idea2022
djl环境: djl系列模块 版本 0.22.1
模型: 官方的英文 en_PP-OCRv3 检测和识别模型(https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/doc/doc_en/models_list_en.md)
模型转换: 按本项目引导成功转换成onnx模型,在转换检测模型时,预先用paddle_infer_shape.py模块对检测模型的shape进行修改,关键修改参数设置为:--input_shape_dict="{'x':[-1,3,-1,-1]},然后再转换模型,并成功转换成onnx格式
应用字典(ppocr_keys_v1.txt): 官方的ppocr_keys_v1.txt,但识别出来的是乱码,后改为en_dict.txt,含95个字符的字典 (https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/ppocr/utils/en_dict.txt)

测试模型(en_dict.txt中的字符作为字典内容),识别一张全英文图片,抛出异常java.lang.IndexOutOfBoundsException: Index 96 out of bounds for length 96。是不是在修改检测模型shape时参数设置错误?或者字典选择错误?好像其它地方都没有太多疑问,因为运行项目中的ch_PP-OCRv3_rec_infer_onnx模型是正常的。恳请老师帮我拨开云雾,再次感谢老师的无私杰出奉献。
核心错误信息如下:

Caused by: ai.djl.translate.TranslateException: java.lang.IndexOutOfBoundsException: Index 96 out of bounds for length 96
	at ai.djl.inference.Predictor.batchPredict(Predictor.java:191)
	at ai.djl.inference.Predictor.predict(Predictor.java:128)
	at com.aias.paddleOCR.recognition.OcrV3Recognition.predict(OcrV3Recognition.java:95)
Caused by: java.lang.IndexOutOfBoundsException: Index 96 out of bounds for length 96
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.util.ArrayList.get(ArrayList.java:427)
	at com.aias.paddleOCR.recognition.PpWordRecognitionTranslator.processOutput(PpWordRecognitionTranslator.java:70)
	at com.aias.paddleOCR.recognition.PpWordRecognitionTranslator.processOutput(PpWordRecognitionTranslator.java:22)
	at ai.djl.inference.Predictor.batchPredict(Predictor.java:172)
@biotech7
Copy link
Author

biotech7 commented Jun 19, 2023

额外的logger:

2023-06-2006:30:11.0362670[W:onnxruntime:,execution_frame.cc:835onnxruntime::ExecutionFrame::VerifyOutputSizes]Expected shape from model of {-1,1,97} does not match actual shape of{1,40,97}{1,40,97}for outputs oft max_2.tmp_0
2023-06-2006:30:11.1175901[W:onnxruntime:,execution_frame.cc:835onnxruntime::ExecutionFrame::VerifyOutputSizes]Expected shape from model of {-1,1,97} does not match actual shape of{1,40,97}{1,40,97}for outputs oft max_2.tmp_0
2023-06-2006:30:11.2691185[W:onnxruntime:,execution_frame.cc:835onnxruntime::ExecutionFrame::VerifyOutputSizes]Expected shape from model of {-1,1,97} does not match actual shape of{1,40,97}for outputs oft max_2.tmp_0```

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

1 participant