-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue with Inference using onnx_infer.py - Non-zero status code returned while running AveragePool node #3
Comments
Sorry for the problem when using the *.onnx file with onnxruntime (a cpu version)! |
Dear Yubo Tan, Thank you for your prompt response. I appreciate your suggestion to use the *.pt files for loading the model with the saved pretrained weights. However, I encountered some issues while attempting to use the *.onnx file for inference with onnxruntime (a cpu version). To replicate the problem, I downloaded the package from your GitHub repository and navigated to the onnx folder. Then, I ran the python onnx_infer.py command, expecting it to load the model using tcct_duke.onnx and perform inference on the provided oct_duke.png image, both located in the same folder. However, I encountered the following error:
I have attached a screenshot of the error for your reference. Could you please provide further guidance on how to resolve this issue or clarify if there are any additional steps I should follow to ensure correct inference using the *.onnx file? Thank you for your time and assistance. |
I also experienced a similar error, which may be due to some dependency package version changes, not just the onnxruntime version. It is recommended not to use *.onnx, just use *.pt file. |
Dear Yubo Tan, Thank you for your response and for sharing your experience with the *.onnx file. Regarding your suggestion to use the *.pt file instead, I noticed that the provided files do not include inference code specifically for *.pt files. Could you please provide guidance on how to use the *.pt file for inference? Could you provide the inference code file against the pt file? Alternatively, is it possible to modify the onnx_infer.py file to perform inference using the *.pt file directly? Your assistance in resolving this issue would be greatly appreciated. Thank you once again for your help and guidance. Best regards |
Thank you for your prompt reply and the suggestion to refer to onnx_save.py for loading the .pt file and turning it into an .onnx file. Your guidance is greatly appreciated! |
Hello, according to your previous help and suggestions, I conducted some experiments. However, I don't quite understand what y[0] represents in the print(y[0].shape) in your figure, because I found that regardless of whether I use random x or my own image, after passing through the model, it always generates a list. This list contains approximately 4 points, each with a size of (1, C, H, W). If I only read one point, for example, using argmax(y[0], dim=1) for classification, I can generate a visualization image. However, the visualization of all y[0] to y[3] points is very poor, completely inconsistent with the metrics obtained during training. How can I use y to generate a reasonable visualization image? How can I use these 4 points together to generate an inference image? |
The output list are used for deep supervision during training phase. y[0] is the prediction map with the largest resolution used for final prediction during test phase. Your result is poor, which maybe is due to the settings of the model. The input size, channels etc params should be the same with the corresponding dataset, which can be found in the manuscript or the code, please check it. |
However, I encountered an issue while using the onnx_infer.py script from the provided source code for inference. Specifically, I am getting the following error:
read: (160, 160, 3)
img.shape (1, 3, 160, 160)
2024-03-24 17:51:37.248948420 [E:onnxruntime:, sequential_executor.cc:494 ExecuteKernel] Non-zero status code returned while running AveragePool node. Name:'AveragePool_191' Status Message: pool.cc:123 Compute kernel_shape num_dims is not compatible with X num_dims.
Traceback (most recent call last):
File "onnx_infer.py", line 44, in
ret = net.forward(img)
File "onnx_infer.py", line 27, in forward
out = self.session.run(None, {"input": img}, )[0].squeeze()
File "/home/dxzhang/miniconda3/envs/yolov7/lib/python3.7/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 200, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running AveragePool node. Name:'AveragePool_191' Status Message: pool.cc:123 Compute kernel_shape num_dims is not compatible with X num_dims.
Steps to Reproduce
Clone the repository from [GitHub link]
Navigate to the task1 directory
Run the onnx_infer.py script with the provided image
Expected Behavior
I expect the onnx_infer.py script to successfully run inference on the provided image without any errors.
Environment
Linux
Python version: 3.7.13
onnxruntime version: 1.14.1
I would appreciate any guidance or suggestions on how to resolve this issue. Thank you.
The text was updated successfully, but these errors were encountered: