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

can't run paddleocr converted model on onnxruntime #1241

Open
pxike opened this issue Apr 26, 2024 · 3 comments
Open

can't run paddleocr converted model on onnxruntime #1241

pxike opened this issue Apr 26, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working

Comments

@pxike
Copy link

pxike commented Apr 26, 2024

**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
    Memory leak in PaddleOCR. PaddleOCR#11639
  • Paddle2ONNX version: 1.2.1

Error report screenshot

other information

@Zheng-Bicheng Zheng-Bicheng added Bug Something isn't working labels May 28, 2024
@Zheng-Bicheng Zheng-Bicheng self-assigned this May 28, 2024
@Zheng-Bicheng
Copy link
Collaborator

Sorry for the late response. Could you provide me with the model? I will troubleshoot the issue.

@Zheng-Bicheng
Copy link
Collaborator

@pxike

@pxike
Copy link
Author

pxike commented May 29, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants