Skip to content
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

Allow to overwrite ONNX Model Shape and multiple input and outputs #208

Open
ankitbko opened this issue Nov 28, 2021 · 3 comments
Open

Allow to overwrite ONNX Model Shape and multiple input and outputs #208

ankitbko opened this issue Nov 28, 2021 · 3 comments

Comments

@ankitbko
Copy link
Member

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 dotnet/machinelearning#3963

@ankitbko
Copy link
Member Author

I am adding another ask to same issue as it deals with same config class - Allow multiple input and output column names to be passed to OnnxModel. The ApplyOnnxModel accepts list of output and input names so OnnxModelConfiguration should also accept a list along with shape data for each.

@ankitbko ankitbko changed the title Allow to overwrite ONNX Model Shape Allow to overwrite ONNX Model Shape and multiple input and outputs Nov 29, 2021
@danbohus
Copy link
Contributor

danbohus commented Dec 6, 2021

Thanks for flagging this! Agreed, the OnnxModel and OnnxModelConfiguration classes should be updated to allow for configuring lists of input/output names, and to enable the shapeDictionary parameter. The change seems relatively straightforward, and we would welcome a PR on this. Let us know if you plan to make this contribution. Otherwise we'll try to get to it in the near future.

@ankitbko
Copy link
Member Author

ankitbko commented Dec 9, 2021

Sure will be happy to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants