Skip to content

ONNX model inference issues with ML.Net #6475

@crazyoutlook

Description

@crazyoutlook

System Information (please complete the following information):

  • OS & Version: Windows 10
  • ML.NET Version: ML.NET v1.6, ML.OnnxRuntime v1.7
  • .NET Version: NET 6.0

Describe the bug
I have an ONNX model which is exported from Azure custom vision. It has single output. My ML.Net code pipeline works fine with this ONNX model with single output. I have another Yolo v4 model which I converted to ONNX but post conversion it has dual output. Due to this, my ML.Net code pipeline is not working. I checked the output details using Netron tool.

I used this link to convert Yolo to ONNX: https://github.com/Tianxiaomo/pytorch-YOLOv4

To Reproduce
Steps to reproduce the behavior:

Use ML.Net to infer a ONNX model

Expected behavior
ML.Net should give inference results

Screenshots, Code, Sample Projects

var pipeline = mlContext.Transforms.ResizeImages(resizing: ImageResizingEstimator.ResizingKind.Fill, outputColumnName: "data", imageWidth: ImageSettings.imageWidth, imageHeight: ImageSettings.imageHeight, inputColumnName: nameof(ImageInput.Image))
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "data", orderOfExtraction: ImagePixelExtractingEstimator.ColorsOrder.AGRB))
.Append(mlContext.Transforms.ApplyOnnxModel(modelFile: modeltoInfer.ModelPath, outputColumnName: "model_outputs0", inputColumnName: "data", gpuDeviceId: gpuDeviceId, fallbackToCpu: fallbackToCpu));

Screenshots:

image

image

Additional context
Is there any ML.Net code which can do inferencing for a ONNX model having dual output ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions