microsoft / microsoft/psi

Allow to overwrite ONNX Model Shape and multiple input and outputs

Open
#208 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
574
Forks
104
Avg merge
19m
Merged PRs (30d)
1

Description

I was unable to run DB_TD500_resnet50.onnx model (https://docs.opencv.org/4.x/d4/d43/tutorial_dnn_text_spotting.html) using OnnxModel as it was throwing following error - Length of memory (1625088) must match product of dimensions (3).

The only way to fix it was to duplicate OnnxModel locally and pass the correct shapeDictionary when applying ONNX Model

this.context.Transforms.ApplyOnnxModel(
      modelFile: configuration.ModelFileName,
      outputColumnNames: new[] { configuration.OutputVectorName },
      inputColumnNames: new[] { configuration.InputVectorName },
      gpuDeviceId: configuration.GpuDeviceId,
      shapeDictionary: new Dictionary<string, int[]>()
          {
             { "input", new[] { 1, 3, 736, 736} }
          });

Request is to allow overriding shapeDictionary when creating OnnxModel. This overriding requirement also exist to run FasterRCNN model https://github.com/dotnet/machinelearning/pull/3963

Contributor guide

Open the contributing guide

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 tracing the OnnxModel creation path and the ApplyOnnxModel call described in the issue, including how shapeDictionary is currently passed. Reproduce the DB_TD500_resnet50.onnx failure and compare it with the FasterRCNN requirement. Done means callers can override the model shape and support multiple inputs and outputs without duplicating OnnxModel.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.