dotnet / dotnet/machinelearning

API for loading ONNX model lacks access to input schema and is not consistent with regular model loading API

Open
#4,335 3 comments 1 reaction 0 assignees View on GitHub
area-ONNX Priority:2
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

Current API for loading models is as follows:
ITransformer mlModel = mlContext.Model.Load(path, out DataViewSchema inputSchema);

Note you have a transformer back and the input schema, plus transformer gives access to output schema as well.
For ONNX the same functionality will look something like this:
var estimator = mlContext.Transforms.ApplyOnnxModel(path);
var dataView = mlContext.Data.LoadFromEnumerable(new ModelInput[] { });
// Fit() will check the input schema of the model against the input dataview you're passing in
var transformer = estimator.Fit(dataView);

Note there's no way to get the input schema, you have to know it before you can do anything with the model. Also Fit() call is confusing and inconsistent with the much cleaner API above, it doesn't actually do anything other than verify the [unavailable from public interface] input schema against the schema that got loaded with the model.

The fix is to bring ONNX model loading API in line with what we have for regular ML.NET models.

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.