Skip to content

Using Onnx trained on Keras with PreprocessInput #5830

@bbday

Description

@bbday

I have issue when i using onnx model trained with keras and preprocess_input, is ResNet50 model,
if i training without preprocess_input on keras it work on ml.net but when i use preprocess_input will not work, according documentation preprocess_input will process image with caffe style that mean:

The images are converted from RGB to BGR, then each color channel is zero-centered with respect to the ImageNet dataset, without scaling.

this work without preprocess_input

var dataschema = mlContext.Data.LoadFromEnumerable(new List<ImageNetData>());
            var transformer =
                mlContext.Transforms.ExtractPixels(outputColumnName: "input_1", nameof(ImageNetData.BitImage), interleavePixelColors: true)
                .Append(mlContext.Transforms.ApplyOnnxModel(modelFile: path, outputColumnNames: new[] { "fc360" }, inputColumnNames: new[] { "input_1" })) //gpuDeviceId:0
                .Fit(dataschema);

i tried this convert from RGB to BGR but i dont see any parameter for zero-centered color mode

mlContext.Transforms.ExtractPixels(outputColumnName: "input_1", nameof(ImageNetData.BitImage), orderOfExtraction: ImagePixelExtractingEstimator.ColorsOrder.ABGR, interleavePixelColors: true)

Maybe i miss something ???

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Doc bugs, questions, minor issues, etc.imageBugs related image datatype tasksquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions