onnx / onnx/models

Resnet batch prediction

Open
#255 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

My apologies if I am missing something obvious.
I wanted to classify batch of 10 images using resnet34v2.onnx downloaded [here].(https://github.com/onnx/models/tree/master/vision/classification/resnet)
I have simplified the example so instead of images lets classify zeros.

batch_size = 10
arr = np.zeros((batch_size, 3, 224, 224), dtype=np.float32)
sess = rt.InferenceSession("resnet34v2.onnx")
input_name = sess.get_inputs()[0].name
result = sess.run(None, {input_name: arr })

The error produced.

onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: data for the following indices
 index: 0 Got: 10 Expected: 1

From this post I gathered that you can specify the input shape during conversion. In this case it should have been (None, 3, 224, 224), but was (1, 3, 224, 224).
Any ideas how to allow batch prediction for already converted model?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with the linked resnet34v2.onnx model and inspect its declared input shape. Investigate how the model was converted and whether this repository contains the source or conversion process. Done means establishing a supported way for the model to accept a batch of 10, or clearly documenting that the existing model cannot do so.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.