Paddle2ONNX
Paddle2ONNX copied to clipboard
can't run paddleocr converted model on onnxruntime
**Please fill in the following information completely so that we can solve the problem quickly, thank you! **
Problem Description paddleOCR converted to onnx model with dynamic input is being run in onnx . first the image needs preprocessing
def preprocess_image(image_path , it = (0, 3, 1, 2) ):
with open(image_path, 'rb') as file:
image_data = file.read()
image_bytes = np.frombuffer(image_data, dtype=np.uint8)
image = cv2.imdecode(image_bytes, cv2.IMREAD_COLOR)
# I would expect your image to be HWC at this point: [H, W, 3]
image_array = image.astype(np.float32) / 255.0
image_array = np.expand_dims(image_array, axis=0) # [1, H, W ,C]
# notice that i reordered the dimensions on transpose !
# N = 1 and C = 3 is moved to the first axis
image_array = np.transpose(image_array, it)
image_array
return image_array
Input names: ['x']
Output names: ['softmax_2.tmp_0']
Input shape :['p2o.DynamicDimension.0',
3,
'p2o.DynamicDimension.1',
'p2o.DynamicDimension.2']
When running the model in the runtime ;
{
"name": "Fail",
"message": "[ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Concat node. Name:'p2o.Concat.2' Status Message: concat.cc:157 onnxruntime::ConcatBase::PrepareForCompute Non concat axis dimensions must match: Axis 2 has mismatched dimensions of 1 and 31",
"stack": "---------------------------------------------------------------------------
Fail Traceback (most recent call last)
Cell In[12], line 3
1 print(x)
2 image_array = preprocess_image(r\"images\\2.jpg\")
----> 3 outputs = session.run(None, {session.get_inputs()[0].name: image_array})
4 print(\"success\")
File c:\\Users\\hamza.kharbouch\\Desktop\\pp\\.conda\\lib\\site-packages\\onnxruntime\\capi\\onnxruntime_inference_collection.py:220, in Session.run(self, output_names, input_feed, run_options)
218 output_names = [output.name for output in self._outputs_meta]
219 try:
--> 220 return self._sess.run(output_names, input_feed, run_options)
221 except C.EPFail as err:
222 if self._enable_fallback:
Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Concat node. Name:'p2o.Concat.2' Status Message: concat.cc:157 onnxruntime::ConcatBase::PrepareForCompute Non concat axis dimensions must match: Axis 2 has mismatched dimensions of 1 and 31"
}
More information :
- Inference engine for deployment: None
- Why you need to convert to ONNX format: CPU memory leaks in normal runtime for paddleOCR and fastDeploy https://github.com/PaddlePaddle/PaddleOCR/issues/11639
- Paddle2ONNX version: 1.2.1
Error report screenshot
other information
Sorry for the late response. Could you provide me with the model? I will troubleshoot the issue.
@pxike
Hello @Zheng-Bicheng , it's this model https://drive.google.com/file/d/1tCa3qzHzHEGq_KqzpAdCt5VLH-4Ym58k/view?usp=sharing which is converted from https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_rec_infer.tar