Skip to content

Update OnnxTransformer Doc XML #5085

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

Merged
merged 2 commits into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Microsoft.ML.OnnxTransformer/doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@
var imageWidth = 224;
var dataFile = GetDataPath("images/images.tsv");
var imageFolder = Path.GetDirectoryName(dataFile);

var mlContext = new MLContext();

var data = TextLoader.CreateLoader(env, ctx => (
imagePath: ctx.LoadText(0),
name: ctx.LoadText(1)))
.Read(new MultiFileSource(dataFile));
var data = mlContext.Data.LoadFromTextFile<ImageData>, <ImagePrediction>(dataFile);

var pipe = data.MakeNewEstimator()
.Append(row => (
row.name,
data_0: row.imagePath.LoadAsImage(imageFolder).Resize(imageHeight, imageWidth).ExtractPixels(interleaveArgb: true)))
.Append(row => (row.name, softmaxout_1: row.data_0.ApplyOnnxModel(modelFile)));
var pipe = mlContext.Transforms.LoadImages("data_0", imageFolder: "images", inputColumnName: nameof(ImageData.ImagePath))
.Append(mlContext.Transforms.ResizeImages("data_0", imageWidth, imageHeight, inputColumnName: "data_0")
.Append(mlContext.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
.Append(mlContext.Transforms.ApplyOnnxModel(modelFile));

TestEstimatorCore(pipe.AsDynamic, data.AsDynamic);
TestEstimatorCore(pipe, data);

var result = pipe.Fit(data).Transform(data);

var output = result.Schema.GetColumnOrNull("softmaxout_1");

var result = pipe.Fit(data).Transform(data).AsDynamic;
result.Schema.TryGetColumnIndex("softmaxout_1", out int output);
using (var cursor = result.GetRowCursor(col => col == output))
{
var buffer = default(VBuffer<float>);
Expand All @@ -71,7 +71,7 @@
getter(ref buffer);
numRows += 1;
}
System.Console.Writeline("Number of rows scored=" + numRows);
System.Console.Writeline("Number of rows scored = " + numRows);
}
</code>
</example>
Expand Down