-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add a batch dimension #39
Comments
Hi @makaveli10 , I've supplied a onnx batch inference tutorial in this notebook, do you try this first? Actually the model exported as pointed in the tutorial support batch inference, I use a batch inference trick as in torchvision. the only thing you need do is just to entry the multiple images inputs to a ort_session = onnxruntime.InferenceSession(export_onnx_name)
# compute onnxruntime output prediction
ort_inputs = dict((ort_session.get_inputs()[i].name, inpt) for i, inpt in enumerate(inputs))
ort_outs = ort_session.run(None, ort_inputs) BTW, the master branch is not stable now, make sure you are using the release/0.2.0 branch now. |
@zhiqwang thanks! I tried the notebook and yes I did try the list input thing also. So what happens is when I create a onnx model with a input list of length 4 it doesnt work for if I have 2 inputs I have to give it some dummy inputs to make it a list of 4 images and that takes more time to run inference. For 1 image time is 0.06 s. For 4 images it's 0.24s. so i don't see a speed up when using multiple images in a list. Correct me if I am wrong or you had different results. |
Hi @makaveli10 ,
Yep, I face the same question as you when I export a onnx model with a input list of length 4, it asked for 4 full image in the API as in my notebooks.
A quick search in https://github.com/microsoft/onnxruntime I can't find a good solution :( If you have good solution, we are welcome for PR or proposal :) and I'll try how to solve this problem later. Maybe a stupid solution is that we could export multiple onnx model supporting various length, such as with length 1, 2, 3 ... And then we determine the onnx model depends on the length of the inputs?
The |
Hi, @makaveli10 In my current limited understanding, I don't think this is a bug, and as such I'm closing this issue. If you have a more flexible method to support the dynamic batch inference, feel free to open a new issue. And let us know if you have further questions. |
I was trying to add a batch dimension to the onnx model and run inference on multiple images concurrently. while doing that faced this issue :
I have added a batch dimension preciously in onnx models by simple expanding the dimension of the input but not in this case. Let me know if you have faced this issue and have any pointers for me?
The text was updated successfully, but these errors were encountered: