dotnet / dotnet/machinelearning

Fault convert to ONNX object detection model

Open
#6,810 3 comments 3 reactions 1 assignee Claimed by @rosebyte View on GitHub
area-ONNX
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

**System Information:**
- OS & Version: Windows 10
- ML.NET Version: ML.NET v3.0.0-preview.23266.6
- .NET Version: .NET 7.0

**Describe the bug**
Fault conversion to ONNX

**To Reproduce**
Steps to reproduce the behavior:
1. Train object detection model by tutorial (https://devblogs.microsoft.com/dotnet/object-detection-ml-dotnet-model-builder/)
2. Try convert model
```charp
public class ModelInput
{
[LoadColumn(0)]
[ColumnName(@"Labels")]
public string[] Labels { get; set; }

[LoadColumn(1)]
[ColumnName(@"Image")]
[Microsoft.ML.Transforms.Image.ImageType(640, 640)]
public MLImage Image { get; set; }

[LoadColumn(2)]
[ColumnName(@"Box")]
public float[] Box { get; set; }

}

public static void Export()
{
var onnxPath = "test.onnx";
var mlContext = new MLContext();
ITransformer mlModel = mlContext.Model.Load(MLNetModelPath, out var _);

var input = new ModelInput[30];
for (int i = 0; i < input.Length; i++)
{
input[i] = new ModelInput
{
Image = MLImage.CreateFromFile(@"demo.jpg")
};
}
IDataView trainingData = mlContext.Data.LoadFromEnumerable(input);
using (var onnx = File.Open(onnxPath, FileMode.OpenOrCreate))
{
mlContext.Model.ConvertToOnnx(mlModel, trainingData, onnx);
}
}
```
3. Got error
System.InvalidOperationException: 'Unsupported type: Microsoft.ML.Data.MLImage'

**Expected behavior**
Got onnx model

**Additional context**
If I try to represent the input as an array [B,3,W,H], it says that it expects an image, when I pass the image, it says that it does not support it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.