Open xunlizhinian1124 opened 7 months ago
Sorry for the problem when using the .onnx file with onnxruntime (a cpu version)! The .pt files are ok to be applied, you can load the model with the saved pretrained weights. Further you can turn the *.pt files to onnx if needed. Best wishes!
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:
_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 numdims.
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.
Best regards
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
You can refer to onnx_save.py, which was used to load the .pt file and turn it to .onnx file. It can be modified to inferring with .pt files.
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.