onnx / onnx/models

Data type error

Open
#257 4 comments 3 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

In the pre-processing sample code snippet:

# input
image_data = preprocess(image)
image_size = np.array([image.size[1], image.size[0]], dtype=np.int32).reshape(1, 2)

image size variable type is set to int32 as:

image_size = np.array([image.size[1], image.size[0]], **dtype=np.int32**).reshape(1, 2)

But tiny Yolo V3 model's input data types are float32. Above (current sample) code gives following error:

    boxes, scores, indices = session.run(None, {"input_1": imgData, "image_shape":imgSize})
  File "/opt/miniconda/lib/python3.7/site-packages/onnxruntime/capi/session.py", line 142, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Unexpected input data type. Actual: (N11onnxruntime17PrimitiveDataTypeIiEE) , expected: (N11onnxruntime17PrimitiveDataTypeIfEE)

Correct sample code should be:

# input
image_data = preprocess(image)
image_size = np.array([image.size[1], image.size[0]], dtype=np.float32).reshape(1, 2)

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 from the pre-processing sample code shown in the issue and check the dtype used for image_size before the session.run call. Update the sample so its input type matches the model, then run the tiny YOLO V3 inference sample and confirm the input data type error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.