jhgan00 / java-ort-example-yolov5

Onnxruntime Java Example: yolov5
34 stars 8 forks source link

ai.onnxruntime.OrtException: Error code - ORT_INVALID_ARGUMENT #5

Closed umi-soft closed 1 year ago

umi-soft commented 1 year ago

Novice Question

Train with yolov8,option batch value 64,run your code has errors

OnnxTensor.createTensor ERROR

ai.onnxruntime.OrtException: Error code - ORT_INVALID_ARGUMENT - message: Got invalid dimensions for input: images for the following indices
 index: 0 Got: 1 Expected: 64
 Please fix either the inputs or the model.

if i set option batch value 16 and retrain,your code can run success。 I guess I need to make changes NUM_INPUT_ELEMENTS and INPUT_SHAPE,but I am clear about the specific meaning of the values and how to modify them.

umi-soft commented 1 year ago

The image size is also 640

jhgan00 commented 1 year ago

Hello. Currently, my code is written without considering dynamic batch sizes. In other words, the code only works with a batch size of 1. Based on the error message, it seems that you exported the trained model to ONNX with a batch size of 64. If you could share the trained model or provide information about the input shape through apps like Netron, I would be able to assist you further.

스크린샷 2023-05-14 오후 12 30 08
jhgan00 commented 1 year ago

In both cases, we need to modify the current code

umi-soft commented 1 year ago

thanks, i get it.