dotnet / dotnet/machinelearning-modelbuilder

[Proposal] Convert ONNX to ML.NET model in Visual Studio

Open
#2,059 4 comments 5 reactions 0 assignees View on GitHub
Feature request Stale
Dominant language
Dockerfile
Stars
285
Forks
66
PR merge metrics
No merged PRs in 30d

Description

## Problem

To use an ONNX model with ML.NET, you create a pipeline that includes the `ApplyOnnxModel` transform. The pipeline then needs to be converted into an `ITransformer` before using the model to make predictions. Therefore, every time you use the model to make predictions, you have to call the `Fit` transform. The challenge with that is now instead of loading the model and calling `Predict` or `Transform`, you have to also generate the `ITransformer`. Unless the application the model is being used in is a console application, you have to create a separate console app or a notebook just to convert the ONNX model into ML.NET.

```csharp
var onxxModelPipeline =
// pre-processing transforms
.Append(ctx.Model.ApplyOnnxModel("outputColName", "inputColName", "model.onnx")
// post-processing transforms

var model = onnxModelPipeline.Fit(emptyIdv);
```

As a result, it's recommended to save the `ITransformer` as an ML.NET model so you can use it just like any other ML.NET model.

## Proposal

In Visual Studio, when I right-click on an ONNX model file, I'd like the option "Convert to ML.NET". In the background, a process takes my model, creates an ML.NET pipeline with the default input and output columns specified by the ONNX model and saves the ML.NET pipeline to my project.

## Things to consider

- Conversion would not include pre-processing and post-processing steps.
- Would the user have control over the input / output columns?

## Related Issues

- [x] #1870
- [x] #1182

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.