How to add custom normalize image data by MlContext.Transform?

20 Views Asked by At

i'm using .NET framwork 4.7.2 and i'm deploying model AI to console app, i get stuck in preprocess data. i have flow preprocess data in python like this : img -= (104, 117, 123) (RGB image) I want to do this with MlContext.Transform lib (the lib which support preprocess data before training and inference model by C#) because i haved this :

MLContext mlContext = new MLContext();

var pipeline = mlContext.Transforms.LoadImages(outputColumnName: "input0", imageFolder: "", inputColumnName: nameof(ImageNetData.ImagePath)) 

.Append(mlContext.Transforms.ResizeImages(outputColumnName: "input0", imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: "input0"))

.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "input0")) 

.Append(mlContext.Transforms.ApplyOnnxModel(modelFile: modelLocation, outputColumnNames: new[] { TinyYoloModelSettings.ModelOutputConf, TinyYoloModelSettings.ModelOutputBox,TinyYoloModelSettings.ModelOutputLandmark }, inputColumnNames: new[] { TinyYoloModelSettings.ModelInput }));

How can i implement this custom normalize after Resize ???. Thank for your help.

0

There are 0 best solutions below