-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
How to do batch inference with onnx model? #9867
Comments
You will need set dynamic axes during exporting ONNX model. Search "dynamic_axes" in https://pytorch.org/docs/stable/onnx.html. |
Thanks for your guidance,That's exactly what I was wondering. |
@MasterGG were you able to implement batch inferencing? I used this code to get inference from model
I am still getting dimension error, It is working fine if I pass a single image and the shape of input_dict is (1,256,256,3) but when I stack multiple images and the of input_dict becomes (2,256,256,3), I get the dimension error. |
I'm facing the same issue. I too exported my model with a dynamic batch input size, but it doesn't seem to be helping. Not sure how to do batch inference. |
@shubhamgoel27 i also have no idea how to do the batched inference after exporting an onnx model with dynamic_axes param (tells me it can't handle shape of Although i found that you can set a fixed batch size on exporting like this:
look at And then you can do the inference like this:
Hope it helps. |
Hi @kopyl , your export onnx code with batch is great, but I have a problem: if my batch doesn't have 10 items it gives an error:
I look forward to receiving your support on this matter. |
@TruongNoDame, please search "dynamic_axes" in torch onnx export document: |
when i do some test for a batchSize inference by onnxruntime, i got error:
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: input.1 Got: 5 Expected: 4 Please fix either the inputs or the model.
the input shape is [1, 3, 224, 224].
how can i do for batch inference? i would be appreciate it , if some examples can show for me?
The text was updated successfully, but these errors were encountered: